【发布时间】:2021-03-02 06:55:53
【问题描述】:
我正在尝试使用 discord.js 在 discord 上制作一个测验机器人,但是当我运行此代码时,即使它不是正确的词,它也会回复。我该如何解决?
client.once('message', msg => {
if (msg.content === 'quiz')
msg.channel.send('Ok quiz time!');
msg.channel.send('Can coding be hard. yes ???? or no ????')
msg.react('????').then(() => msg.react('????'));
const filter = (reaction, user) => {
return ['????', '????'].includes(reaction.emoji.name) && user.id === msg.author.id;
};
msg.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '????') {
msg.reply('correct answer');
msg.channel.send ('Good job!')
} else {
msg.reply('Incorrect.');
}
})
.catch(_collected => {
msg.reply('You ran out of time.');
})
});
当我说一个不和谐的随机词时,我的机器人会用“编码难不难。是 ???? 或否 ????”回复它
【问题讨论】:
-
bruh ur if 语句将在它正下方的行结束.. USE BRACKETS PLS 因为
msg.channel.send('Ok quiz time!');下面的所有其他行都是OUTSIDE if 语句
标签: node.js discord discord.js bots