繁体   English   中英

有没有办法自动回复/回应 Discord 机器人的消息 (Mudae)?

[英]Is there a way to automatically reply/react to a Discord bot's message (Mudae)?

如果消息包含我想要的句子或值,我正在尝试制作一个程序来响应或响应 Discord 机器人的消息。

我想到的机器人是 Mudae,一个动漫人物扭蛋生成器。 该程序应键入“message.react(":heart:")",或者如果我想要的角色确实出现,则单击默认声明反应

你必须使用:

这是一个简单的例子:

bot = commands.Bot(command_prefix='!')

@bot.event
async def on_message(message):
    if not message.author.bot: #Check if author is not a bot
        return
    if ':heart:' in message.content:
        message.add_reaction('❤️')
    elif 'hello' in message.content:
        message.channel.send(f'Hi {message.author.mention} :)')

    await bot.process_commands(message)

PS: on_message事件会覆盖命令,因此您需要await bot.process_commands(message)才能将命令与on_message事件一起使用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM