eVen-gits / EDH_matchmaker

8 stars 2 forks source link

Discord integration #8

Open aljazfrancic opened 3 days ago

aljazfrancic commented 3 days ago

Seen your TODO, if you need help implementing Discord integration, here's a snippet that has everything you need. https://github.com/aljazfrancic/fnm-code-bot/blob/main/bot.py await chan.send(msg) sends message to the specified Discord channel. The real pain lies in configuring the Discord app and DISCORD_TOKEN, but it's pretty self explanatory. https://discord.com/developers/applications It's possible to send directly to a certain guild (Discord server), given their guild ID, which can be found though Discord's inbuilt developer mode. In that case you obviously also need to provide the channel name. Both of which could be pulled from the GUI in your case, or perhaps a file (less user friendly, but useful for storing defaults etc.).

Ping/assign me if you want help implementing Discord integration.

aljazfrancic commented 3 days ago

Even simpler/less bloated version:

import discord
import requests

url = 'https://discord.com/api/webhooks/:id/:secret'

session = requests.Session()
webhook = discord.webhook.SyncWebhook.from_url(url, session=session)

webhook.send('Example Content')