Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
其他命令不';不行。(Python,Discord.py)_Python_Discord_Discord.py - Fatal编程技术网

其他命令不';不行。(Python,Discord.py)

其他命令不';不行。(Python,Discord.py),python,discord,discord.py,Python,Discord,Discord.py,这段代码运行良好,但它会阻止其他命令工作 我把这个代码放在最后。但其他命令仍然不起作用 如何修复错误?请阅读 在代码末尾使用wait bot.process_命令(消息),与其他命令一起运行事件函数。在on_消息事件末尾添加bot.process_命令(消息)。另外,在函数定义中应该有一个message参数。我必须在末尾编写此代码吗?或者我应该在bot.run()之前的整个代码末尾写它吗?在on_message事件的末尾。这是一行正确的代码,但我认为应该在file=openpyxl.load_工

这段代码运行良好,但它会阻止其他命令工作

我把这个代码放在最后。但其他命令仍然不起作用

如何修复错误?

请阅读


在代码末尾使用
wait bot.process_命令(消息)
,与其他命令一起运行事件函数。

on_消息
事件末尾添加
bot.process_命令(消息)
。另外,在函数定义中应该有一个
message
参数。我必须在末尾编写此代码吗?或者我应该在bot.run()之前的整个代码末尾写它吗?在
on_message
事件的末尾。这是一行正确的代码,但我认为应该在
file=openpyxl.load_工作簿(“level.xlsx”)之前写它。
@bot.event 
async def on_message(ctx) :
    file = openpyxl.load_workbook("level.xlsx")
    sheet = file.active
    exp = [100, 200, 400, 700, 1100, 1600, 2200, 2900, 3700, 4600, 5600]
    i = 1
    while True :
        if sheet["A" + str(i)].value == str(ctx.author.id) :
            sheet["B" + str(i)].value = sheet["B" + str(i)].value + 2
            if sheet["B" + str(i)].value >= exp[sheet["C" + str(i)].value - 1] :
                sheet["C" + str(i)].value = sheet["C" + str(i)].value + 1
                await ctx.channel.send("Level UP !!\nLevel : " + str(sheet["C" + str(i)].value) + "\nExp : " + str(sheet["B" + str(i)].value))
            file.save("level.xlsx")
            break
        if sheet["A" + str(i)].value == None :
            sheet["A" + str(i)].value = str(ctx.author.id)
            sheet["B" + str(i)].value = 0
            sheet["C" + str(i)].value = 1
            file.save("level.xlsx")
            break
        i += 1