簡體   English   中英

當我的機器人或其他機器人在命令中使用時,如何讓我的機器人說些什么? (不和諧.py)

[英]How can I make my bot say something when it or another bot is used in the command? (discord.py)

我試圖讓我的機器人“檢查”我的命令中提到的人是否是機器人,但我不確定如何。 這是我的代碼:

@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)}')

謝謝,

您可以使用member.bot來檢查該成員是否為 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)}')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM