【发布时间】:2022-01-20 21:34:47
【问题描述】:
我不确定如何使用 .toLowerCase() 使我的不和谐命令不区分大小写,这应该很简单,但我对此真的很陌生
exports.execute = async (client, message, args) => {
let userBalance = client.eco.fetchMoney(message.author.id);
if (userBalance.amount < 1) return message.channel.send("Looks like you don't have the funds for that <:smallsob:922970676283977748>.");
let item = args[0];
if (!item) return message.channel.send("What do you wish to purchase");
let hasItem = client.shop[item];
if (!hasItem || hasItem == undefined) return message.reply("Sorry, that doesn't exist <:smallsob:922970676283977748> Jinn is currently working on this feature so sorry if it's not fully functional");
let isBalanceEnough = (userBalance.amount >= hasItem.cost);
if (!isBalanceEnough) return message.reply("Your balance is insufficient. You need <:daisyy:922974700144062474> "+hasItem.cost+" to buy this item.");
let buy = client.eco.removeMoney(message.author.id, hasItem.cost);
let itemStruct = {
name: item.toLowerCase(),
prize: hasItem.cost
};
client.db.push(`items_${message.author.id}`, itemStruct);
return message.channel.send(`You purchased **${item}** for **<:daisyy:922974700144062474> ${hasItem.cost}**.`);
};
exports.help = {
name: "buy",
aliases: [],
usage: `buy <item>`
};
【问题讨论】:
-
检查邮件内容时,请尝试使用
.toLowerCase()。这将要求您使用小写格式的所有命令。 -
请解释此代码中的哪些问题以及您的期望。
标签: javascript node.js discord discord.js