0
votes

I am trying to make a spam command that only certain roles can use, but when I run my code I get a bunch of errors

code:

@bot.command()
@commands.has_any_role('The Great Mountain Chicken', 'The Great Frogs', 'The Great Toads')
async def spam(ctx, member):
    for i in range(20):
        await ctx.send(f'{member} why do you do this to me. IT BURNS')

errors:

Ignoring exception in command spam:
Traceback (most recent call last):
  File "C:\Users\Jude\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\bot.py", line 903, in invoke
    await ctx.command.invoke(ctx)
  File "C:\Users\Jude\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 851, in invoke
    await self.prepare(ctx)
  File "C:\Users\Jude\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 786, in prepare
    await self._parse_arguments(ctx)
  File "C:\Users\Jude\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 697, in _parse_arguments
    transformed = await self.transform(ctx, param)
  File "C:\Users\Jude\AppData\Local\Programs\Python\Python36\lib\site-packages\discord\ext\commands\core.py", line 542, in transform
    raise MissingRequiredArgument(param)
discord.ext.commands.errors.MissingRequiredArgument: member is a required argument that is missing.
1
How do you call your command?Nurqm

1 Answers

0
votes

You defined member argument that you need to specify on command's call (!spam <member>)

If you want to get user that issued command (author of message), you need to get it from context (ctx):

@commands.has_any_role(...)
@bot.command()
async def spam(ctx):
    for _ in range(20):
        await ctx.send(f"{ctx.author.mention} why do you do this to me. IT BURNS")