E
E
EcoTry2021-05-23 11:16:27
Python
EcoTry, 2021-05-23 11:16:27

Where can I put an argument in a discord bot?

There is a command !data, information about users is stored there. I can add a database to the database, but I also want to !data showsee what is there through the command:

@bot.command()
async def data(ctx, arg1, arg2, arg3, arg4, arg5):
    if arg1 == None:
        ctx.send(f'{ctx.author.name}, не хватает агругумента')
    elif arg1 == 'add':
        now = datetime.datetime.now()
        RegTime = now.strftime("%d-%m-%Y %H:%M")
        cur.execute('INSERT INTO data VALUES(?, ?, ?, ?, ?)',
                    (arg2, arg3, arg4, arg5, RegTime))
    elif arg1 == 'show':
        x = cur.execute('SELECT * FROM data').fetchall()
        await ctx.send(x)

An error pops up:

discord.ext.commands.errors.MissingRequiredArgument: arg2 is a required argument that is missing.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Shitskov, 2021-05-23
@EcoTry

In this case, you need to use a variable number of arguments

async def data(ctx, *args):
    if not args:
        ctx.send(f'{ctx.author.name}, не хватает агругумента')
    elif args[0] == 'add':
#и т.д....

https://discordpy.readthedocs.io/en/latest/ext/com...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question