Skip to content

How do I use discord.py in a non-interactive way (without loop)? #6278

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

You must be logged in to vote

Run your code and log off within on_ready.

e.g.

class Client(discord.Client):
    async def on_ready(self):
        # my code here...
        await self.close()

client = Client()
client.run('token')

I would have recommended webhooks which are more lightweight if your use case was just sending messages but it seems you want to do more and it seems to involve the gateway machinery as well so this is probably the easiest thing to do what you want.

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@bandwiches
Comment options

@honzajavorek
Comment options

@15696
Comment options

@15696
Comment options

@honzajavorek
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
4 participants