M
M
matveyyyyyyyy2020-11-18 19:03:49
Node.js
matveyyyyyyyy, 2020-11-18 19:03:49

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)
    }
  })
}


At the output I get: [object Object]: user: = user

PS : user: this is how it is displayed in the browser simply, there are no problems with the role, it's just not displayed in the Embed Message...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pythonMyLife, 2020-12-08
@pythonMyLife

https://leovoel.github.io/embed-visualizer/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question