Skip to main content

Discord.js, msg.content.toString().toLowerCase().startsWith() not working

I'm coding a discord bot using discord.js. I'm trying to make an if statement:

    const Discord = require('discord.js');
    require('dotenv').config();
    const client = new Discord.Client();
    
    const config = require("./config.json");
    
    client.on('message', (msg) => {
        if (msg.content.toString().toLowerCase().startsWith(`${config.prefix}${config.customcommand}`)) {
            msg.channel.send("It's working");
        }
    }

client.login(config.token)

Config.json:

    {
          "token": "xxx",
          "prefix": "C!",
          "customcommand": "Ship"
    }

Now I'm aware that .toLowerCase() only works with strings, that's why I used toString() but it doesn't work. Nothing is happening when I type the command (C!Ship)

Via Active questions tagged javascript - Stack Overflow https://ift.tt/SnzXYF5

Comments