0
votes

I am trying to make multi guild reaction roles command with MongoDb,

        await ctx.send(embed=gen_embed("React to this message with reaction you want to use.\n**Don't use Nitro Emoji that is not in this server.**"))
        reaction,user = await self.bot.wait_for("reaction_add",timeout=30,check=reaction_check)
        try:
            #emoji = await ctx.guild.get_emoji(reaction.Emoji)
        except:
            return await ctx.send(embed=gen_embed("<:xmark:771032946915934298> | I can't see that emoji."))

This is the part of code, I am stucked at. Bot asks the user to react with an emoji, then bot should try to find that emoji (emoji can be default or custom), if the bot can find the emoji , it would store id or something like that of emoji and if it can't then it would return by saying I can't see...

Now the thing is Idk how to check if bot can see that emoji or not and what exactly to store for the event. I tried reading docs but docs doesn't seem to be written for beginners.

2
Have you tried using on_raw_reaction_add instead? I think this gives you more information even in the case where the bot cannot "see" a custom emojiThomas Kowalski
That's what idk how touser13878676
@ThomasKowalski that's misleading. He's doing the correct way with bot.wait_for("reaction_add",... his question is what his check function should look like check=reaction_check. If he was going the on_raw_reaction_add route it'd be a huge mess since he will lose the context the command was created in.Tin Nguyen

2 Answers

0
votes

Instead of get_emoji use str(reaction.emoji) == '👍'.
Hope this helps
You can find more info about this on https://discordpy.readthedocs.io/en/latest/api.html#emoji This only checks for 1 emoji

0
votes

Ok guys, idk if I wasn't able to explain the question properly or it is just you, this is what worked for me.

        await ctx.send(embed=gen_embed("React to this message with reaction you want to use.\n**Don't use Nitro Emoji that is not in this server.**"))
        reaction,user = await self.bot.wait_for("reaction_add",timeout=30,check=reaction_check)
        if cancel_check(role) is True:
            return await ctx.send(embed=gen_embed('<:xmark:771032946915934298> | Cancelled!'))
        elif cancel_check(role) is False:
            if isinstance(reaction.emoji,str):
                await msg.add_reaction(str(reaction.emoji))
            else:
                try:
                    emoji = await ctx.guild.fetch_emoji(reaction.emoji.id)    
                    await msg.add_reaction(emoji) 
                except:
                    return await ctx.send(embed=gen_embed("<:xmark:771032946915934298> | I can't see that emoji."))

I am sure there will be a much better way of doing this but this is what I got for now. I will edit my answer if I find any better way. Also reaction_check is nothing , it just checks if the author is the user who started the setup.