Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discord integration #8

Open
aljazfrancic opened this issue Sep 27, 2024 · 1 comment
Open

Discord integration #8

aljazfrancic opened this issue Sep 27, 2024 · 1 comment

Comments

@aljazfrancic
Copy link
Contributor

aljazfrancic commented Sep 27, 2024

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
Copy link
Contributor Author

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')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant