W
W
wz2021-03-20 11:25:09
Python
wz, 2021-03-20 11:25:09

I can't figure out why discord.py is failing?

I have a code for spam messages:

@bot.command(pass_context=True)
async def spam(ctx, m):
    await ctx.message.delete()
    count = 0
    while count < int(m):
        await ctx.send("@everyone crush")
        count += 1


An error pops up that m does not exist, although it should be.
discord.ext.commands.errors.MissingRequiredArgument: m is a required argument that is missing.
Help(

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dewerro, 2021-03-20
@rensly

Your team is doing great. Just when you call the command in the discord, indicate the number of messages.
Example: $spam 5
Also, in such cases it is better to use a for loop

@bot.command()
async def spam(ctx, m):
    for i in range(int(m)):
        await ctx.send("@everyone crush")

I
ivanrotzer, 2021-03-20
@ivanrotzer

I advise you to switch to discord.js.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question