im trying to run multiple commands for my discord bot, bot for some reason one singular command is not running. This is the code in my main.js file:
client.on('message', message => {
if(!message.content.startsWith(prefix) || message.author.bot) return
const args = message.content.slice(prefix.length).trim().split(' ');
const command = args.shift().toLowerCase();
if(command === 'petfeed') {
client.commands.get('petfeed').execute(message, args, Discord);
}else if(command === 'petwater') {
client.commands.get('petwater').execute(message, args, Discord);
//this is one of the commands that runs perfectly fine. The command has virtually identical code to the petfeed command in its file but with a few small changes
});
Here is the command that i am trying to run:
const db = require('quick.db')
module.exports = {
name: 'petfeed',
description: 'feeds your pet',
execute: async (message, args, Discord) => {
let user = message.author
let fullness = await db.fetch(`fullness_${user.id}`)
let food = await db.fetch(`food_${user.id}`)
if(fullness === null) fullness = 0;
if(food === null) food = 0;
if(fullness < 3 && food >= 1) {
db.add(`fullness_${user.id}`, 1)
db.subtract(`food_${user.id}`, 1)
}
}
}
I have other very similar commands that run perfectly fine, but this command does nothing when i try to run it, and it doesn't give back any errors.
Somehow changing the name to petfood in both the main.js file and the command file fixed the issue. If i change it back to petfeed it stops working again.