Skip to content

What's the best way to execute a script once, rather than going into an event loop? #5896

Answered by Rapptz
jammur asked this question in Q&A
Discussion options

You must be logged in to vote

You should probably use a webhook.

The library supports webhooks in both async (aiohttp) and sync (requests) mode so once you get your webhook URL you can use the requests library and post to it. For example:

from discord import Webhook, RequestsWebhookAdapter

webhook_url = 'your webhook URL goes here'
webhook = Webhook.from_url(webhook_url, adapter=RequestsWebhookAdapter())

# Send a message to the channel
webhook.send('Hello world!')

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jammur
Comment options

Answer selected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants