0
votes

I've been working on coding my own discord bot in python and I've been trying to implement reacting to specific messages in a certain way will you give you a certain role. I figured out how to get this to work custom discord emojis, but I'm struggling to get it to work with native discord emojis. I know I that i should try be using the emoji's unicode somehow but i just can't figure it out

#roles for hemisphere and native fruit
#first part - emoji id, second part - role id
#CUSTOM EMOJIS
hemisphere = {693662576936222811:[693663054788821092],
693662585953714256:[693663114914168913]
            }
#NATIVE DISCORD EMOJIS
native_fruit = {693711698082660427:[693711520953270293],
693711724024430633:[693711530197516289],
693711811312353330:[693711572312391721],
693711739744813056:[693711538623742042],
693711786582474752:[693711553257799720]
                }
hemisphere_id=693914783979667506
native_fruit_id=693914786773205103

#add roles
@bot.event
async def on_raw_reaction_add(reaction):
    if reaction.user_id==bot.user.id:
        return
    if not ((reaction.emoji.id in hemisphere) or (reaction.emoji.id in native_fruit)):
        return


    guild = await bot.fetch_guild(reaction.guild_id)
    user = await guild.fetch_member(reaction.user_id)

#CUSTOM EMOJIS
    if reaction.message_id == hemisphere_id:
        emojiid = hemisphere.get(reaction.emoji.id)
        id =emojiid[0]
        await user.add_roles(guild.get_role(id))
#NATIVE DISCORD EMOJIS
    elif reaction.message_id == native_fruit_id:
        emojiid = native_fruit.get(reaction.emoji.id)
        id = emojiid[0]
        await user.add_roles(guild.get_role(id))        
    else:
        return

I'm new to python in general so I'm having trouble figuring out how to move forward

1
Can you be more specific about what the issue is? - AMC

1 Answers

0
votes

For native emoji's you have to paste the actual emoji icon rather than the id. You can get it by typing \:emoiji_id: in discord and replace emoji_id with the id of the emoji. For example, cucumber is a native emoji for discord, to use it in your code, you have to type \:cucumber: in discord and it will return 🥒. Then you can copy and paste 🥒 into your code in place of native_fruit_id. You can also go on https://getemoji.com/ and copy and paste from there. Hope that helps!