这是我的第一个问题,很抱歉,如果它是重复的,我不知道如何用词
我想做的是假设我有一个>;我的命令,它将产生随机数量的硬币从100到500,当我检查>;平衡表显示了该金额,但我希望它仅适用于我,因此当其他人这样做时>;巴尔:如果有意义的话,它将只显示他们开采的数量
这是原始代码
from discord import *
from discord.ext import *
import random
from discord.ext import commands
bot = commands.Bot(command_prefix='>')
coinbalance = 0
@bot.command()
async def mine(ctx):
coinsget = random.randint(100,500)
coinstr = str(coinsget)
global coinbalance
await ctx.send(":pick: you went mining and collected "+coinstr+" coins! :moneybag:")
coinbalance = coinsget + coinbalance
@bot.command()
async def bal(ctx):
balstr = str(coinbalance)
await ctx.send("your balance = "+balstr)
bot.run('my token')
这是我试图使用ctx.author的原始版本,但我想不出我能做的任何事情
您应该使用mongodb或sqlite之类的数据库。下面是python文档中的sqlite示例https://docs.python.org/3/library/sqlite3.html。您必须使用特定参数(guild.id、member.id、cash)将信息存储在数据库中以保存成员数据
相关问题 更多 >
编程相关推荐