Ask coding questions

← Back to all posts
How do I close a discord bots dms
DrSovietSoviet (0)

Recently my bot has been used by people it's not supposed to be used by via dms how would I disable it's dms as a quick work around?

Answered by InvisibleOne (3263) [earned 5 cycles]
View Answer
InvisibleOne (3263)

If you are using commands you can use

or you can check if there is a server on the message

xfinnbar (211)

Override the default on_message event and check if the channel is a DM before processing commands. If you are using bot instead of client for discordpy, then change client to bot: