On discord.py 1.7.3, when I want to make sure a command errors out if it is given arguments, I do:
@commands.command(name='hi')
@commands.is_owner()
async def hi(self, ctx, *, arg=None):
if arg:
raise commands.TooManyArguments
else:
await ctx.send(f'hi')
I wanted to create a check decorator has describe in the documentation, to have something a bit more elegant: https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#checks
So I did:
def has_args():
def predicate(ctx):
print(ctx.args, ctx.kwargs)
if len(ctx.args) > 2 or kwargs:
raise commands.TooManyArguments
return True
return commands.check(predicate)
...
@commands.command(name='hi')
@commands.is_owner()
@has_args()
async def hi(self, ctx, *, arg=None):
await ctx.send(f'hi')
but ctx.args and ctx.kwargs are always empty, no matter the number of arguments I pass to the command (aka {prefix}hi 1 2 3 yield the same print as {prefix}hi)
Is there a better way to do this? What am I missing?