'Having trouble using default emoji for discord in discord.js reaction role
I am making a role reaction and it is not working with default emojis no matter what I try. This is what I have right now if someone could help me out. It does work with custom emojis though. Here is my reaction role file that I have with the default emoji. It doesn't give any errors but it just says undefined where the emoji is supposed to go.
const firstMessage = require('./first-message')
module.exports = client => {
const channelD = '895718398791667722'
const getEmoki = emojiName => client.emojis.cache.find(emoji => emoji.name === emojiName)
const digitalEmoji = '🔒'
const emojis = {
lock : '🔒Digital\'s Daring Detective Decoder'
}
const reactionIds = []
let emojiText = '**Congrats!**\n***Add a reaction to claim a role***\n'
for (const key in emojis){
const emoji = getEmoki(key)
reactionIds.push(emoji)
const role = emojis[key]
emojiText += `${emoji} = ${role}\n`
}
firstMessage(client, channelD, emojiText, reactionIds)
const handleReaction = (reaction, user, add) => {
if(user.id === '939257079875657758'){
return
}
const emoji = reaction._emoji.name
const { guild } = reaction.message
const roleName = emojis[emoji]
if (!roleName){
return
}
const role = guild.roles.cache.find(role => role.name === roleName)
const member = guild.members.cache.find(member => member.id === user.id)
if (add) {
member.roles.add(role)
} else {
member.roles.remove(role)
}
}
client.on('messageReactionAdd', (reaction, user) => {
if (reaction.message.channel.id === channelD) {
handleReaction(reaction, user, true)
}
})
client.on('messageReactionRemove', (reaction, user) => {
if (reaction.message.channel.id === channelD) {
handleReaction(reaction, user, false)
}
})
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
