@bot.command()
async def coincount(ctx,*, member: discord.Member = None):
member = ctx.author if not member else member
member_id = str(member.id)
with open('users.json', 'r') as f:
users = json.load(f)
coins = users[member_id]['coins']
if member_id in users:
if coins > 1:
await ctx.send(f'{member.mention} has {coins} coins.')
if coins == 1:
await ctx.send(f'{member.mention} has {coins} coin.')
else:
await ctx.send(f'{member.mention} has no coins.')
没有回溯。如果该成员位于文件中,则该漫游器会发送适当的消息,但如果成员不在文件中,它将不执行任何操作。