Home > Net >  Is there a way to disable my discord bot's direct messages in discord.py?
Is there a way to disable my discord bot's direct messages in discord.py?

Time:11-05

I have 2 bots and another one of them includes alot of slash commands, I don't want anyone to have access to use these commands in the bot's direct messages.

I have tried to find a way to disable my bot's direct messages but couldn't find any.

CodePudding user response:

You can use the guild_only decorator/check while building your command. This ensures, despite the commands maybe showing up, that one can't use them in the direct messages of the bot:

from discord.ext import commands

@commands.guild_only()
# [Rest of your code]

Read more about it here: Command.guild_only

  • Related