0

I am trying to make a discord bot with an economy, everything was going well until I got to the sell command. When I try to sell, the bot just doesn't respond. It only responds on the lines where it will return message.channel.send

Can anyone help me?

Code:

if (message.content === `${prefix}sell`) {
    let item = message.content.split(" ").slice(1).join(" ");
    if (!item) return message.channel.send("Please enter what you want to sell!");
    item = item.toLowerCase();

    if (animals.includes(item) === false) return message.channel.send("That is not a valid thing to sell!");

    let inventory = db.get(`Data_${message.author.id}.inv`);
    if (inventory.includes(item) === false) return message.channel.send("You don't have a " + item + "!");

    let price = prices[animals.indexOf(item)];

    let embed = new Discord.MessageEmbed()
        .setTitle("Sold!")
        .setDescription("You sold 1 " + item + " and got " + price.toString() + " for it.")
        .setColor(embedColor);

    message.channel.send(embed);

    message.channel.send("Sold.");

    db.add(`Data_${message.author.id}.coins`, price);

    let newInventory = inventory.splice(inventory.indexOf(item), 1);
    db.set(`Data_${message.author.id}.inv`, newInventory);
}

Things I have tried:

Logging each line to see where it stops, it will send an error message if you don't meet a requirement, but if you meet it the bot just doesn't respond.

Turning lines of code into comments to see what is not working (This didn't help me)

Jakye
  • 6,440
  • 3
  • 19
  • 38
  • That means the !item is true? I don't know more without extra information – Yolomep Mar 13 '21 at 19:39
  • When you log each line where does it stop? – Wright Mar 13 '21 at 19:42
  • The problem, is if something doesn't meet the requirement it sends an error message, but if I do follow the requirements, it is supposed to give money, and send a message. This isn't happening however. – Tactical Turtle Mar 13 '21 at 20:00

0 Answers0