How do you have a bot add a reaction using a custom emoji?

前端 未结 2 1527
伪装坚强ぢ
伪装坚强ぢ 2020-12-11 07:21

I\'m trying to add a custom emoji as a reaction to a message using discord.py version 0.16.12 and I\'m unable to get it functional. Here\'s the code I\'m using:



        
2条回答
  •  情书的邮戳
    2020-12-11 08:00

    You can use the utility function discord.utils.get to get the appropriate Emoji object.

    from discord.utils import get
    
    @bot.event
    async def on_message(message):
        # we do not want the bot to reply to itself
        if message.author == bot.user:
            return
        if ':EmojiName:' in message.content:
            emoji = get(bot.get_all_emojis(), name='EmojiName')
            await bot.add_reaction(message, emoji)
    

提交回复
热议问题