Skip to content

Instantly share code, notes, and snippets.

@Zzz9194
Created April 20, 2020 03:36
Show Gist options
  • Save Zzz9194/97dec3f9d444c025657e0ff013995396 to your computer and use it in GitHub Desktop.
Save Zzz9194/97dec3f9d444c025657e0ff013995396 to your computer and use it in GitHub Desktop.
import sys
import requests
import discord
from discord import Webhook, RequestsWebhookAdapter
def sendhook(url):
hookLink = requests.get(url).json()
hookId = hookLink['id']
hookToken = hookLink['token']
print(hookinfo(url=url))
if input("Proceed? Y/N: ").lower() in ['n','no']:
pass
else:
# Webhook adapter Requests/Discord
webhook = discord.Webhook.partial(hookId, hookToken, adapter=RequestsWebhookAdapter())
embed = discord.Embed(title="State Bureau of Investigations",description="All tipline submissions will now be automatically reproduced in this channel in the form of an embed",color=discord.Color.dark_blue())
embed.set_author(name="Tipline Submissions",icon_url='https://cdn.discordapp.com/attachments/557966999628677135/699909528333975622/545377342298652689.png')
# Webhook sent -> Respective channel
webhook.send(embed=embed)
print("Webhook sent!")
def main():
# Check if a URL was provided as an argument
try:
sendhook(sys.argv[1])
except:
sendhook(input("Please provide a webhook URL: "))
def hookinfo(url):
# Webhook information retrieved -> the URL itself
hookLink = requests.get(url).json()
hookId = hookLink['id']
hookToken = hookLink['token']
hookName = hookLink['name']
guildId = hookLink['guild_id']
channelId = hookLink['channel_id']
# Return the info
return f"WebhookId: {hookId}\nWebhookToken: {hookToken}\nWebhookName: {hookName}\nWebhookGuild&Channel: {guildId},{channelId}"
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment