簡體   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