Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading