我是编码的新手,尤其是对不和谐的机器人。我需要有关不一致的bot代码的帮助,该代码可以帮助我存储信息。 可以说我想列出一些信息: 即: 我希望命令像!addtolist一样,然后提供电子邮件密码和名称
!addtolist lorem@ipsum.com 1234 Lorem
此后,漫游器将存储信息。当我要求列表(!list命令)时,我希望该机器人向我显示我输入的所有电子邮件密码和名称的列表。 即
!列表
谢谢
答案 0 :(得分:0)
你可以这样做:
bot = commands.Bot(command_prefix='!')
bot_list = []
@bot.command(help='Adds an item to a list')
async def addtolist(ctx, item):
global bot_list
bot_list.append(item)
ctx.send(f'item added to list successfully\nList is now: {bot_list}')
@bot.command(help='Shows bot list')
async def showlist(ctx)
ctx.send(bot_list)