我试图创建一个变量,每次调用命令/函数时,它都会添加到该变量中
import discord
import asyncio
from discord.ext import commands
botToken = 'TOKEN'
bot = commands.Bot(command_prefix = '#')
@bot.event
async def on_ready():
print('Bot is online and ready.')
varible1 = 1
async def changeVariable(ctx, *, orderItem):
varible1 = variable1 + 1
print(variable1)
它告诉我变量在赋值之前没有赋值/引用。有没有一种方法可以使它像一个全局函数?如果需要,我可以尝试提供更多细节
您可以在导入下面的文件顶部创建一个全局变量。然后,只要在输入函数时增加变量,如下所示
相关问题 更多 >
编程相关推荐