Im trying to make a command that I could use in every server, but when others use “-help” it doesn’t show in the list of commands. I know the normal way to do this would be:
if ctx.author.id == myID: #do some code
But if I do it like this, the user can still see that the command exists when using “-help”. Is there any way to get around this? Is there a @commands.command @commands.is_user(myID) ?
There are three options, you can either make a check, make a decorator, or make a global check:
def is_user(ctx): return not ctx.author.id == myID @bot.command() @commands.check(is_user) async def foo(ctx): ...
def is_user(func): def wrapper(ctx): return not ctx.author.id == myID return commands.check(wrapper) @bot.command() @is_user async def foo(ctx): ...
- global check
@bot.check async def is_user(ctx): return not ctx.author.id == myID
If a check returns
commands.CheckFailure is going to be raised, you can make an error handler and send something like “You can’t use this command” or whatever.