【发布时间】:2020-12-11 12:06:29
【问题描述】:
我正在制作这个新机器人并使用了 awaitmessage 功能。当用户使用 cmd '!gangsug' 时,机器人应该会问一个问题,例如 - “请选择一个选项 - RP 或战斗”,当用户使用它应该给出答复的选项。 (这是一个嵌入)。对于用户给出的 2 个答案,我给出了两种不同的答复。(一个用于回答“RP”,另一个用于回答“Fight”)。在这种情况下,机器人对两个答案给出相同的答案。如果用户键入“RP”或“Fight”,则给出相同的回复 由机器人。我希望你理解这个问题。代码将在下面给出(ofc只是问题出现的部分)
if (message.content === `${prefix}gangsug`) {
message.reply('Hey there! Please choose a option.\n'
+ 'Confirm with `RP` or with `Fight`.');
// First argument is a filter function - which is made of conditions
// m is a 'Message' object
message.channel.awaitMessages(m => m.author.id == message.author.id,
{max: 1, time: 30000}).then(collected => {
// only accept messages by the user who sent the command
// accept only 1 message, and return the promise after 30000ms = 30s
// first (and, in this case, only) message of the collection
if (collected.first().content.toLowerCase() == 'RP') {
message.reply(suggestgang1);
}
else
message.reply(suggestgang2);
message.reply(suggestgang3);
}).catch(() => {
message.reply('No answer after 30 seconds, req canceled.');
});
} }
);
**是的,这是代码。如果您能通过说明问题和替换此代码的固定代码来给出答案,那就太好了。谢谢:) **
【问题讨论】:
标签: javascript node.js discord.js