0

我试图为我的 discord bot 运行多个命令,bot 由于某种原因一个单一的命令没有运行。这是我的 main.js 文件中的代码:

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
});

这是我要运行的命令:

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

我有其他非常相似的命令运行得非常好,但是当我尝试运行它时,这个命令什么也没做,并且它不会返回任何错误。

4

1 回答 1

0

在 main.js 文件和命令文件中以某种方式将名称更改为 petfood 解决了这个问题。如果我将它改回宠物饲料,它会再次停止工作。

于 2021-04-26T04:09:09.823 回答