How can I add a global check registration for app_commands? #9293
Answered
by
ika2kki
Ibrahim2750mi
asked this question in
Q&A
-
There are functions dedicated in |
Beta Was this translation helpful? Give feedback.
Answered by
ika2kki
Mar 8, 2023
Replies: 1 comment 5 replies
-
Hi Ibrahim, You can subclass 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 bot = commands.Bot(
command_prefix="?",
intents=discord.Intents.default(),
tree_cls=MyCommandTree
) |
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
Ibrahim2750mi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Ibrahim,
You can subclass
CommandTree
and override theinteraction_check
method, which behaves as a global check for all commands.For example,
If you're using
ext.commands.Bot
as the client instance, you can attach this tree to the bot via thetree_cls
keyword argument in the bot constructor: