【问题标题】:Having issues with making a reaction post another embed on Discord.js在 Discord.js 上进行另一个嵌入后的反应时遇到问题
【发布时间】:2021-06-09 06:26:10
【问题描述】:

我在让嵌入有反应时遇到问题,当你对它做出反应时,它会在不和谐聊天中发布另一个嵌入,这都是试图制作一个解释数学和代数的机器人,我还需要在一个文件中执行此操作,我找不到任何教程,我不知道该怎么做...

谢谢!

module.exports = {
    name: 'algebra',
    description: 'This is a test embed command',
    async execute(message, args, Discord, client){
        const newEmbed = new Discord.MessageEmbed()
        .setColor('#3B0099')
        .setThumbnail('https://i.imgur.com/a/Wnjoo1L') 
        .setTimestamp() 
        .setAuthor('This was written by (REDACTED)') 
        .setDescription('Once finished reading this you should know a lot about algebra!') 
        .setFooter('Algebra') 
        .addFields(
            {name: 'The Basics Behind Algebra', value: 'Algebra can be a simpal concept if approached correctly, as in you must know what the steps you will take are and complete them in the correct order and way. Algebra mainly focuses on substituting numbers with letters. If you want to learn more about this please react with the letter A'}, 
            {name: 'The Theory of Algebra', value: 'The theory of Algebra is one that is... If you want to learn more about this please react with the letter B'} 
            )
            message.channel.send(newEmbed).then((msg) =>{
                msg.react('1️⃣');
                msg.react('2️⃣');
                msg.react('3️⃣');
                msg.react('4️⃣');
                msg.react('5️⃣');
                msg.react('6️⃣');
                msg.react('7️⃣');
                msg.react('8️⃣');
                msg.react('9️⃣');
                msg.react('????');
            }).catch((err)=>{
                throw err;
            });

    }
    
}

【问题讨论】:

    标签: node.js discord discord.js embed


    【解决方案1】:

    请阅读有关收集器的文档 (https://discordjs.guide/popular-topics/collectors.html) 这是一个例子

        let ageEmbed = new Discord.MessageEmbed()
        .setTitle('Please, specify your age with the reactions below...')
        .addField('1️⃣', '17-')
        .addField('2️⃣', '18+')
        .setColor('#FF1493')
      let msg = await message.channel.send(ageEmbed)
      await msg.react('1️⃣');
      await msg.react('2️⃣');
    
    
      const filter_age = (reaction, user) => {
        return reaction.emoji.name === '1️⃣' || '2️⃣' && user.id === message.author.id && !user.bot;
      }
    
      const collector_age = msg.createReactionCollector(filter_age, {
        time: 30000,
        max: 1
      });
    
    
      collector_age.on('collect', async (reaction, user) => {
        if (reaction.emoji.name === '1️⃣') {
          let embed2 = new Discord.MessageEmbed()
          .setDescription(`You reacted with :one:`)
          .addField('Hey', ":one:");
          message.channel.send(embed2)
        } else {
      let embed = new Discord.MessageEmbed()
      .setDescription("You reacted with :two:")
      message.channel.send(embed)
    }
    

    })

    如果你对一个做出反应,机器人会发送一个嵌入内容,说“你对 :one: 做出反应”。否则,该机器人将发送一个嵌入内容,说“你的反应是:two:

    【讨论】:

      猜你喜欢
      • 2021-09-02
      • 2020-08-04
      • 2017-02-18
      • 2020-03-18
      • 2020-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-05
      相关资源
      最近更新 更多