I am trying to make a discord bot that finds emojis in messages in a channel and then reacts with these messages.
My code is:
if message.channel.id == 645647298423613453:
custom_emojis = re.findall(r'<:\w*:\d*>', message.content)
custom_emojis = [e.split('<')[1].replace('>', '') for e in custom_emojis]
for item in custom_emojis:
await message.add_reaction(item)
and it perfectly reacts with all custom emojis (I used resources from here and here). So, now I have to implement the same for normal emojis.
The first issue is how to find if there are any of them in the message sent. In threads like this or this it is used the module emoji.UNICODE_EMOJI
. However, as it is said here you cannot use it, right?
The second issue is that the only way that I have found how do react with them is this.
I know that await message.add_reaction("")
works perfectly but I lack the icon itself.
When I run this:
msg = message.content.split()
print("msg is ", msg)
I get this list: msg is ['', '️\u200d⚧️', 'dasdass', 'aadsdasasd', '<:test2:1066037921007808612>']
while my original discord message was the knife icon, Trans flag, two random string and a custom emoji.
So the final question is: How do I get the non-custom emojis, and how do I react with them in the format that I have extracted them.
For reference my code is hosted in replit.com and I have used this source to make the bot.