简体   繁体   English

尝试使用 quick.db 制作一个经济型机器人,但我的命令不起作用

[英]Trying to make a Economy bot with quick.db, but my command is not working

Basically, I am trying to create a discord.js/quick.db economy system and I tried making a simple balance command, using a tutorial for guidance, and this command won't execute, but no errors are showing in the logs.基本上,我正在尝试创建一个 discord.js/quick.db 经济系统,并尝试制作一个简单的平衡命令,使用教程作为指导,该命令不会执行,但日志中没有显示错误。

I tried researching how to do it, following other tutorials, but it just leads me back to this error.我尝试按照其他教程研究如何做到这一点,但它只会让我回到这个错误。 I have already installed all the required packages for this.我已经为此安装了所有必需的软件包。

const Discord = require('discord.js')
const db = require('quick.db')

module.exports.run = async (bot, message, args) => {

    let bal = db.fetch(`money_${message.guild.id}_${message.author.id}`)

    if (bal === null) bal = 0;

    message.channel.send('You have a balance of `' + bal + '`')

}

I am receiving no errors, but the command just won't execute, I even searched the logs to make sure there were absolutely no errors, but nothing is showing up.我没有收到任何错误,但该命令无法执行,我什至搜索了日志以确保绝对没有错误,但没有显示任何内容。

I have a similar script and mines working, I didn't use我有一个类似的脚本和地雷工作,我没有使用

if (bal === null) bal = 0

My code is this:我的代码是这样的:

let goldAmount = db.get(`money_${message.author.id}`)

        let balEmbed = new Discord.RichEmbed()
            .setTitle(`${message.author.username}'s Gold`)
            .setColor([0,200,20])
            .setDescription(`${goldAmount} Gold`)

        await message.channel.send(balEmbed);

You don't need to send it as a RichEmbed, you can just do await message.channel.send(goldAmount);您不需要将其作为 RichEmbed 发送,您只需执行await message.channel.send(goldAmount);

This works for me!这对我有用!

let user = message.mentions.members.first() || message.author;
let bal = db.fetch(`money_${message.guild.id}_${user.id}`)

if (bal === null) bal = 0;

let bank = await db.fetch(`bank_${message.guild.id}_${user.id}`)  
if (bank === null) bank = 0;

let moneyEmbed = new Discord.MessageEmbed()
    .setColor("RANDOM")  
    .setDescription(`**${user}'s Balance**\n\n__Pocket:__${bal}\n__Bank:__${bank}\n__Overall:__ ${bank + bal}`);  
message.channel.send(moneyEmbed);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM