简体   繁体   English

当我的机器人或其他机器人在命令中使用时,如何让我的机器人说些什么? (不和谐.py)

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

I'm trying to make my bot "check" to see if the person mentioned in my command is a bot, but I'm not really sure how.我试图让我的机器人“检查”我的命令中提到的人是否是机器人,但我不确定如何。 Here is my code:这是我的代码:

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

Thanks,谢谢,

You can use member.bot to check if the member is bot or not.您可以使用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.

相关问题 如何让我的“说”命令删除命令消息,同时保留机器人的消息? (discord.py) - How can I make my “say” command delete the command message, while keeping the bot's message? (discord.py) 如果在 discord.py 中一段时间未使用命令,如何让我的机器人执行某些操作? - How do I make my bot do something if a command hasn't been used for awhile in discord.py? 如何让我的机器人根据选择的数字说出不同的话? (不和谐.py) - How to make my bot say something different depending on the number chosen? (discord.py) 尝试在使用命令时让机器人记录一些东西 discord.py - Trying to make bot log something when a command is used discord.py 试图在我的 discord.py 重写机器人中创建一个 !say 命令 - Trying to create a !say command in my discord.py rewrite bot 试图让 discord.py 机器人在提到它时说些什么,没有回应 - Trying to make discord.py bot say something when its gets mentioned, doesnt respond 如何让discord bot在discord.py中的命令后接受输入? - How can I make a discord bot take input after a command in discord.py? 我如何制作使我的机器人离开服务器的命令(discord.py) - How do i make a command that make my bot leave from the server (discord.py) 如何让 discord.py bot 不需要前缀? - How can I make a discord.py bot not require a prefix? 如何在 discord.py 中使机器人不区分大小写? - How can I make a bot not case sensitive in discord.py?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM