So I have created my django website and. I want to run my discord bot inside my django website And also **can I use the signals to send a message on my server if post have been crated ** So any one can help me how to do that
Asked
Active
Viewed 39 times
1 Answers
0
It is really hard to run both a discord bot and a Django website in a single script. I wouldn't recommend it.
The easiest approach would be using the discord API and making requests to it.
However, if you still want to use specifically discord.py
you can use webhooks:
Firstly create a webhook:
Go to Server Settings > Integrations > Webhooks > Create Webhook
And copy the webhook URL
import requests # pip install requests
from discord import SyncWebhook
webhook_url = "your webhook URL"
session = requests.Session()
webhook = SyncWebhook.from_url(webhook_url, session=session)
# To send a message
webhook.send("New post has been created")

Łukasz Kwieciński
- 14,992
- 4
- 21
- 39
-
Thanks man you solved my problem I actually didn't know about webhooks – 7mood May 30 '23 at 18:03