@bot.command()
async def level(ctx) :
file = openpyxl.load_workbook("level.xlsx")
sheet = file.active
exp = [10, 20, 40, 70, 110, 160, 220, 290, 370, 460, 560]
i = 1
while True :
if sheet["A" + str(i)].value == str(ctx.message.author.id) :
sheet["B" + str(i)].value = sheet["B" + str(i)].value + 2.5
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.send("Level UP !!\n현재 레벨 : " + 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.message.author.id)
sheet["B" + str(i)].value = 0
sheet["C" + str(i)].value = 1
file.save("level.xlsx")
break
i += 1
I am creating a system that automatically builds up exps when any chat is chatted and level up when certain exps are filled.
When using @bot.command(), it worked well, but I must enter level to make it work, and when you switch to @bot.event and chat any time, the following error appears:
AttributeError: 'Message' object has no attribute 'message'
How can I fix the error?