Easiest way to check if an emoji is default or belongs to the server
I'm trying to have a bot copy message reactions over to another channel for a starboard. What's the easiest way to check if a bot can "use" reaction emoji? Basically trying to prevent this:
13 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.If the bot is in the server where the emoji exists, it can use it. Though you could check
BaseGuildEmojiManager
but I think that is a unnecessary step
If the emoji is from another guild, it will need the perms to use external emojis I believe
To prevent that, you should use the <:emoji:id> identifierIs ReactionEmoji/GuildEmoji .toString reliable or should I manually do
<:emoji:id>
?toString method should give you the identifier
@probablyraging Does it matter if the emoji comes from a guild the bot is not in?
I'm having some trouble getting things working, even with the external emoji permission
Yes, the bot won't be able to use it
Ah, ok. How do I detect if an emoji comes from a server the bot is not in?
if(reaction.emoji instanceof GuildEmoji || reaction.emoji.id === null)
?
Not sure if instanceof GuildEmoji
is reliableWould probably be the best bet
Ah ok
I'll try
(emoji.guild && emoji.id) || emoji.id === null
That won't tell you if the bot can access it.
emoji.guild
will always be truthy
Check if the client has the emoji.guild.id
in it's cacheAlrighty will do, thanks so much 🙂
Np