Answer the question
In order to leave comments, you need to log in
How to use embed?
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)
}
})
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question