samedi 20 juin 2020

For some reason my if statement triggers no matter what

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')

})

So essentially my problem is that when I test the bot any message sent in any server the bot is in is responded with Your new prefix is asdasd Ive tried to troubleshoot but Ive hit my limit and cant figure it out. Im using discord.js and have received no errors in my console! Thanks for any help!

Aucun commentaire:

Enregistrer un commentaire