我想为我的机器人创建一个销售命令,并且我已经使用教程进行了平衡、库存和购买命令。我创造了一些赚钱的方法,比如日常命令和工作命令。这是我的购买命令代码。
const Discord = require("discord.js")
const db = require("quick.db")
module.exports = {
name: "buy",
description: "buy an item",
execute: async(client, message, args) => {
let author = db.fetch(`money_${message.author.id}`)
if (!args[0]) {
message.channel.send("What are you trying to buy?")
}
if (args[0] === "sword") {
if (author < 200) {
message.reply("You don't have enough ihscoins to buy this item!")
} else {
let items = db.fetch(message.author.id, { items: [] })
db.push(message.author.id, "Sword")
message.channel.send("You have bought 1x Sword!")
db.subtract(`money_${message.author.id}`, 200)
}
}
}
}
我将如何使用它创建一个卖出命令?