Answer the question
In order to leave comments, you need to log in
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 show
see 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)
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
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':
#и т.д....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question