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
d.js toolkit
d.js toolkit14mo ago
• 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.
probablyraging
probablyraging14mo ago
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> identifier
jr
jr14mo ago
Is ReactionEmoji/GuildEmoji .toString reliable or should I manually do <:emoji:id>?
probablyraging
probablyraging14mo ago
toString method should give you the identifier
jr
jr14mo ago
@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
probablyraging
probablyraging14mo ago
Yes, the bot won't be able to use it
jr
jr14mo ago
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 reliable
d.js docs
d.js docs14mo ago
property GuildEmoji#guild The guild this emoji is part of
probablyraging
probablyraging14mo ago
Would probably be the best bet
jr
jr14mo ago
Ah ok I'll try (emoji.guild && emoji.id) || emoji.id === null
probablyraging
probablyraging14mo ago
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 cache
jr
jr14mo ago
Alrighty will do, thanks so much 🙂
probablyraging
probablyraging14mo ago
Np
Want results from more Discord servers?
Add your server
More Posts