1 回答
TA贡献1786条经验 获得超13个赞
您必须在使用它们的每个函数的开头声明您正在使用每个全局变量(或者至少在读取/分配给它们之前):
USER_DOING_SETUP = False
USER_SETUP = 0
@client.command(aliases=['rr', 'reactionroles'])
async def reactionrole(ctx, user, arg):
global USER_DOING_SETUP
global USER_SETUP
if arg == "setup":
if USER_DOING_SETUP == False:
userId = user.id
USER_SETUP = userId
USER_DOING_SETUP = True
await ctx.send(f"TEST REACTION ROLES TYPE {BOT_PREFIX}!rr cancel TO CANCEL")
else:
await ctx.send("Setup is used by another user")
elif arg == "cancel":
USER_DOING_SETUP = True
USER_SETUP = 0
await ctx.send("setup was cancled :)")
@client.event
async def on_message(message):
global USER_DOING_SETUP
global USER_SETUP
if message.author != client.user:
if USER_DOING_SETUP == False:
await message.channel.send("false")
elif USER_DOING_SETUP == True:
if USER_SETUP == message.author.id:
await message.channel.send("true")
else:
await message.channel.send("false")
添加回答
举报