Skip to content
Discussion options

You must be logged in to vote

Hi Ibrahim,

You can subclass CommandTree and override the interaction_check method, which behaves as a global check for all commands.
For example,

import discord
from discord import app_commands

class MyCommandTree(app_commands.CommandTree):
    async def interaction_check(self, interaction: discord.Interaction) -> bool:
        ...

If you're using ext.commands.Bot as the client instance, you can attach this tree to the bot via the tree_cls keyword argument in the bot constructor:

bot = commands.Bot(
    command_prefix="?",
    intents=discord.Intents.default(),
    tree_cls=MyCommandTree
)

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@Ibrahim2750mi
Comment options

@ika2kki
Comment options

@Soheab
Comment options

@Ibrahim2750mi
Comment options

@Soheab
Comment options

Answer selected by Ibrahim2750mi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants