我做了一个不和谐的机器人,其中有一个rob命令,如下所示:
@client.command(aliases=['rb'])
@commands.cooldown(2, 60, commands.BucketType.user)
async def rob(ctx,member : discord.Member):
if not member == ctx.author and discord.Status.offline and member.bot:
await open_account(ctx.author)
await open_account(member)
bal = await update_bank(member)
if bal[0]<100:
await ctx.send('It is useless to rob them :(')
return
earning = random.randrange(0,bal[0])
await update_bank(ctx.author,earning)
await update_bank(member,-1*earning)
await ctx.send(f'{ctx.author.mention} You robbed {member} and got ֍{earning} ')
else:
await ctx.send('hey stupid, you seem stupid cuz u r either robbing urself or a bot')
我已经添加了if函数,想要检查提到的成员是否不是作者和离线机器人,但它不起作用。该命令即使在离线用户和机器人上也有效(它不适用于作者,但我希望它不适用于这三个人中的任何一个)
你也可以添加我的机器人来检查功能- https://discord.com/api/oauth2/authorize?client
发布于 2021-11-16 21:34:05
试试这个,我已经测试过了,它很管用,所以它也适用于你。
@client.command(aliases=['rb'])
@commands.cooldown(2, 60, commands.BucketType.user)
async def rob(ctx,member : discord.Member):
if member == ctx.author or ctx.author.status == discord.Status.offline or member.bot:
await ctx.send('hey stupid, you seem stupid cuz u r either robbing urself or a bot')
return
await open_account(ctx.author)
await open_account(member)
bal = await update_bank(member)
if bal[0]<100:
await ctx.send('It is useless to rob them :(')
return
earning = random.randrange(0,bal[0])
await update_bank(ctx.author,earning)
await update_bank(member,-1*earning)
await ctx.send(f'{ctx.author.mention} You robbed {member} and got ֍{earning} ')
https://stackoverflow.com/questions/69999217
复制