Javascript Discord.js在反应后编辑消息

Javascript Discord.js在反应后编辑消息,javascript,discord,discord.js,Javascript,Discord,Discord.js,我刚刚开始使用javascript尝试使用discord.js设置discord机器人。我想使用这个机器人作为一种“简单”的方式来组织袭击。因此,人们只需点击图标即可登录raid const Discord = require('discord.js'); const bot = new Discord.Client(); 。。。标记、前缀等 bot.on('message', message => { if (message.content.startsWith(PREFIX)

我刚刚开始使用javascript尝试使用discord.js设置discord机器人。我想使用这个机器人作为一种“简单”的方式来组织袭击。因此,人们只需点击图标即可登录raid

const Discord = require('discord.js');
const bot = new Discord.Client();
。。。标记、前缀等

bot.on('message', message => {
    if (message.content.startsWith(PREFIX)) {
        let args = message.content.substring(PREFIX.length).split(" ");
。。。一些检查命令的东西

message.channel.send('RaidID: ' + RaidID + '\nRaid: GOS \nRaid Leader: <@' + message.author.id + '> \nDate: ' + args[2] + '\nTime: ' + args[3]).then(messageReaction => {
                                            messageReaction.react('✅');
                                        });
message.channel.send('RaidID:'+RaidID+'\n援助:GOS\n援助领导人:\n日期:'+args[2]+'\n时间:'+args[3])。然后(messageReaction=>{
messageReaction.react('✅');
});

到目前为止,代码工作正常。它检查日期和时间正常。现在我想检测是否有人对消息做出了反应,并通过编辑消息在消息中提及他。我只是不知道如何使用
waitreactions
。或者如果它甚至使用
waitreactions
,你可以替换当前的消息功能

message.channel.send('RaidID: ' + RaidID + '\nRaid: GOS \nRaid Leader: <@' + message.author.id + '> \nDate: ' + args[2] + '\nTime: ' + args[3]).then(messageReaction => {
                                            messageReaction.react('✅');
                                        });
message.channel.send('RaidID:'+RaidID+'\n援助:GOS\n援助领导人:\n日期:'+args[2]+'\n时间:'+args[3])。然后(messageReaction=>{
messageReaction.react('✅');
});
使用此功能:

message.channel
    .send(
        "RaidID: " +
            RaidID +
            "\nRaid: GOS \nRaid Leader: <@" +
            message.author.id +
            "> \nDate: " +
            args[2] +
            "\nTime: " +
            args[3]
    )
    .then((messageReaction) => {
        messageReaction.react("✅");
        messageReaction.awaitReactions((args, user) => {
            return !user.bot && args._emoji.name === "✅";

        }, { max: 1 }).then(reaction => {
            // SOMEONE REACTED
            console.log('REACTION');
        });
    });
message.channel
.发送(
“RaidID:”+
雷迪德+
“\n援助:GOS\n援助领导人:\n援助:+
args[2]+
“\n时间:”+
args[3]
)
.然后((messageReaction)=>{
messageReaction.react(“✅");
messageReaction.waitingreactions((参数,用户)=>{
return!user.bot&&args.\u emoji.name==”✅";
},{max:1})。然后(反应=>{
//有人作出反应
console.log('REACTION');
});
});

它在promise的
中添加
.awaitReactions
函数,然后添加
。它检查用户和表情符号是否做出了反应✅. 如果反应正确,将调用
//某人作出反应的部分。

您可以替换当前的消息函数

message.channel.send('RaidID: ' + RaidID + '\nRaid: GOS \nRaid Leader: <@' + message.author.id + '> \nDate: ' + args[2] + '\nTime: ' + args[3]).then(messageReaction => {
                                            messageReaction.react('✅');
                                        });
message.channel.send('RaidID:'+RaidID+'\n援助:GOS\n援助领导人:\n日期:'+args[2]+'\n时间:'+args[3])。然后(messageReaction=>{
messageReaction.react('✅');
});
使用此功能:

message.channel
    .send(
        "RaidID: " +
            RaidID +
            "\nRaid: GOS \nRaid Leader: <@" +
            message.author.id +
            "> \nDate: " +
            args[2] +
            "\nTime: " +
            args[3]
    )
    .then((messageReaction) => {
        messageReaction.react("✅");
        messageReaction.awaitReactions((args, user) => {
            return !user.bot && args._emoji.name === "✅";

        }, { max: 1 }).then(reaction => {
            // SOMEONE REACTED
            console.log('REACTION');
        });
    });
message.channel
.发送(
“RaidID:”+
雷迪德+
“\n援助:GOS\n援助领导人:\n援助:+
args[2]+
“\n时间:”+
args[3]
)
.然后((messageReaction)=>{
messageReaction.react(“✅");
messageReaction.waitingreactions((参数,用户)=>{
return!user.bot&&args.\u emoji.name==”✅";
},{max:1})。然后(反应=>{
//有人作出反应
console.log('REACTION');
});
});
它在promise的
中添加
.awaitReactions
函数,然后添加
。它检查用户和表情符号是否做出了反应✅. 如果反应正确,将调用
//某人反应的部分。

谢谢-我想我理解它是如何工作的。即使它只能检测到一个反应,我也可以找到检测所有5个反应的解决方案。谢谢-我想我理解它是如何工作的。即使它只能检测到1个反应我可以找到检测所有5个我需要检测的反应的解决方案。