0

I would like my bot on discord to send a message when anyone types a word or a sentence. However, that sentence contains an emoji. How can I make the bot see the emoji? If there is no emoji, it works perfectly, the bot sends the wanted message but I can't figure out how to include the emoji.

I'd like the emoji in the part of the following code snippet, where currently I have XXXX.

async def on_message(self, message):
        word_list = ['Lanfeust got 1 XXXX zombie eye']

        # don't respond to ourselves
        if message.author == self.user:
            return

        messageContent = message.content
        if len(messageContent) > 0:
            for word in word_list:
                if word in messageContent:
                    await message.channel.send('Nice EYE <@459303124037926915>')

I have tried ['I want :apple: apple'] Name of the emoji I have tried ['I want 908223460097011743 apple'] Id of the emoji

The bot doesn't catch up on it.

Thank you in advance

  • Does this answer your question? [Python Bot use custom Emoji](https://stackoverflow.com/questions/51982806/python-bot-use-custom-emoji) – SuperStormer Nov 11 '21 at 05:40
  • Hey there, welcome to Stackoverflow! I am a bit confused by your question. What do you mean by 'make the bot see the emoji'? What is the expected input the user should provide? – Bagle Nov 11 '21 at 06:37
  • I want my bot to reply something when some use this entire sentence : I want XXXX apple (XXXX being an emoiji) It works perfectly if I set it up without emoiji but not with it. I tried word_list = ['I want <:emoji_name:emoji_id> apple'] but it doesn't work. – Maximvaulch Nov 11 '21 at 06:45
  • One thing you can do as part of debugging is write a message with that emoji yourself and then fetch it using discord.py and try to see what it returns, thats the string you will need to match in your code. – typedecker Nov 11 '21 at 08:47
  • Try to fetch content of all messages sent to the bot and print them, then send a message with this emoji, copy the content that it prints. Thats the character that represents the emoji. You can replace your XXXX with that character you copied. – typedecker Nov 11 '21 at 08:52
  • For example using :scream: emoji gives as the character. – typedecker Nov 11 '21 at 08:52

1 Answers1

0

You can use unicode emojis. To get unicode emojis go to https://unicode.org/emoji/charts/full-emoji-list.html

and a simple example :

async def on_message(self, message):
        word_list = ['I want  apple']
        await ctx.send(random.choice(word_list))
Dj Walkzz
  • 492
  • 3
  • 10