Decorator Functions

This is the page which outlines all the available functions in the package, and their uses

@has_<id_type>_id(id: int)

Used to check if the Command <Type>'s ID is the same as the one passed into the Decorator

#Check for User ID

@commands.command()
@check.has_user_id(394320584089010179)
async def command(ctx):
    ..function code..

The 4 ID Types are User, Channel, Guild & Message

@has_<id_type>_id_in(ids: Iterable[int])

Used to check if the Command <Type>'s ID is the same as any ID in the Iterable Object (List, Tuple, etc) passed into the Decorator

#Check for User IDs

ids = (394320584089010179, 678162226955288606, 739843804009594882)

@commands.command()
@check.has_user_id_in(ids)
async def command(ctx):
    ..function code..

@has_<name_type>_name(name: str)

Used to check if the Command <Type>'s Name is the same as the one passed into the Decorator

#Check for Channel Name

@commands.command()
@check.has_channel_name("bot-commands")
async def command(ctx):
    ..function code..

The 3 Name Types are User, Channel, Guild

@has_<name_type>_name_in(names: Iterable[str])

Used to check if the Command <Type>'s Name is the same as any Name in the Iterable Object (List, Tuple, etc) passed into the Decorator

#Check for Channel Names

names = ("bot-commands", "bots", "bot-spam")

@commands.command()
@check.has_user_name_in(names)
async def command(ctx):
    ..function code..

@is_guild_owner()

Used to check if the Command Author is the Guild's Owner

@commands.command()
@check.is_guild_owner()
async def command(ctx):
    ..function code..

@is_not_guild_owner()

Used to check if the Command Author is not the Guild Owner

@commands.command()
@check.is_not_guild_owner()
async def command(ctx):
    ..function code..

@has_args(number: int)

Used to check if the Number of Arguments passed into the function is the same as the Number passed into the Decorator

@commands.command()
@check.has_args(3)
async def command(ctx, x, y):
    ..function code..

@has_args_atleast(number: int)

Used to check if the Number of Arguments passed into the function is greater than or equal to the Number passed into the Decorator

@commands.command()
@check.has_args_atleast(3)
async def command(ctx, x, y, z):
    ..function code..

Last updated

Was this helpful?