0

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) ?

2 Answers2

1

There are three options, you can either make a check, make a decorator, or make a global check:

1.

def is_user(ctx):
    return not ctx.author.id == myID

@bot.command()
@commands.check(is_user)
async def foo(ctx):
    ...
  1. decorator
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):
    ...
  1. global check
@bot.check
async def is_user(ctx):
    return not ctx.author.id == myID

If a check returns False, 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.

Reference:

Łukasz Kwieciński
  • 14,992
  • 4
  • 21
  • 39
0

https://discordpy.readthedocs.io/en/latest/ext/commands/api.html#help-commands

Help commands can have a hidden attribute, which makes them not show up in the help command.

@commands.command(..., hidden=True)
def my_command(...):
    ...
sytech
  • 29,298
  • 3
  • 45
  • 86