const firstMessage = require('./first-message')
const Discord = require('discord.js')
const client = new Discord.Client()
module.exports = (client) => {
const channelId = '776788346034716775'
const getEmoji = (emojiName) =>
client.emojis.cache.find((emoji) => emoji.name === emojiName)
const emojis = {
user: 'user',
}
const reactions = []
const fgfg = new Discord.MessageEmbed()
.setTitle(`Нажми на реакцию для получения роли!\n\n` + emojis)
let emojiText = fgfg
for (const key in emojis) {
const emoji = getEmoji(key)
reactions.push(emoji)
const role = emojis[key]
emojiText += `${emoji} = ${role}\n`
}
firstMessage(client, channelId, emojiText, reactions)
const handleReaction = (reaction, user, add) => {
if (user.id === '776781640398536714') {
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 === channelId) {
handleReaction(reaction, user, true)
}
})
client.on('messageReactionRemove', (reaction, user) =>{
if (reaction.message.channel.id === channelId) {
handleReaction(reaction, user, false)
}
})
}
На выходе получаю: [object Object]:user: = user
P.S. :user: так в браузере отображается просто, с ролью проблем нет, просто не отображается это все в Embed-Сообщении...