【发布时间】:2020-10-11 01:42:34
【问题描述】:
bot.on('message', async msg => {
let args = msg.content.split(" ");
if(!msg.guild) return;
if(msg.author.bot) return;
if (msg.content === '<prefix>') {
const req = await GuildModel.findOne({ id: msg.guild.id });
if (!req) return msg.reply('Sorry! doc doesnt exist.');
return msg.reply(`Found a document! Prefix: ${req.prefix} Suffix: ${req.suffix}`);
}else if(msg.content.includes(`<setprefix>`)) {
const req = await GuildModel.findOne({ id: msg.guild.id });
if(!req) return msg.reply('Sorry there was an error!');
await GuildModel.findOneAndUpdate({ id: msg.guild.id }, { $set: { suffix: `${args[1]}`}}, { new: true})};
return msg.channel.send('Your new prefix is asdasd')
})
所以本质上我的问题是,当我测试机器人时,在机器人所在的任何服务器中发送的任何消息都会以Your new prefix is asdasd 进行响应,我试图排除故障,但我已经达到了我的极限并且无法弄清楚。我正在使用 discord.js,并且在我的控制台中没有收到任何错误!感谢您的帮助!
【问题讨论】:
-
请添加一些显示行为的示例输入。
-
在任何频道中发送任何内容都会导致机器人发送
Your new prefix is asdasd这一行
标签: javascript if-statement discord discord.js