How do I close a discord bots dms
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?
If you are using commands you can use
or you can check if there is a server on the message
@bot.event async def on_message(message): if not message.server: return
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:
@client.event # or bot if there is error async def on_message(message): if not isinstance(message.channel, discord.TextChannel): client.process_commands(message)