【问题标题】:How can I make my bot say something when it or another bot is used in the command? (discord.py)当我的机器人或其他机器人在命令中使用时,如何让我的机器人说些什么? (discord.py)
【发布时间】:2020-10-21 22:24:47
【问题描述】:

我正在尝试让我的机器人“检查”以查看我的命令中提到的人是否是机器人,但我不确定如何。这是我的代码:

@client.command(aliases=['Noob', 'NOOB'])
async def noob(ctx, member: discord.Member):
    member = member.mention
    text = [ f'{member} is a certified Noob:tm:',
               f'{member} is a noob!!',
               ctx.author.mention + f' calls {member} a noob, but they use a Uno reverse card',
               ctx.author.mention + f' attemts to call {member} a noob, but fails.',
               f'{member} is the biggest noob there is!!!',
               f'{member} is a noob, but a really cool one tbh :eyes:',
               ctx.author.mention + f' *thinks* {member} is a noob']

    if [this is where I'm trying to add the check] == True:
        await ctx.send('sorry, i will not betray my kind :pensive:')
    else:
        await ctx.send(f'{random.choice(text)}')

谢谢,

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    您可以使用member.bot 来检查该成员是否为机器人。

    @client.command(aliases=['Noob', 'NOOB'])
    async def noob(ctx, member: discord.Member):
        mention= member.mention
        text = [ f'{mention} is a certified Noob:tm:',
                   f'{mention} is a noob!!',
                   ctx.author.mention + f' calls {mention} a noob, but they use a Uno reverse card',
                   ctx.author.mention + f' attemts to call {mention} a noob, but fails.',
                   f'{mention} is the biggest noob there is!!!',
                   f'{mention} is a noob, but a really cool one tbh :eyes:',
                   ctx.author.mention + f' *thinks* {mention} is a noob']
    
        if member.bot:
            await ctx.send('sorry, I will not betray my kind :pensive:')
        else:
            await ctx.send(f'{random.choice(text)}')
    

    【讨论】:

      猜你喜欢
      • 2021-05-11
      • 2021-10-05
      • 1970-01-01
      • 2019-12-23
      • 1970-01-01
      • 2021-04-14
      • 2023-03-12
      • 1970-01-01
      • 2021-10-07
      相关资源
      最近更新 更多