I have this code:
const Command = require("../Structures/Command.js");
const { menu } = require("../data/menu.json");
module.exports = new Command({
name: "order",
description: "Make an order",
async run(message, args, client){
args.toString().toLowerCase();
switch(args[1]){
case menu[1]:
message.reply(`accepted your order for ${menu[1]}!`);
break;
case menu[0]:
message.reply(`accepted your order for ${menu[0]}`);
break;
case menu[2]:
message.reply(`accepted your order for a ${menu[2]}`);
break;
default:
message.reply(`sorry, we either don't serve that here, or you didn't say what you want to order`);
}
}
})
And what I want it to do:
if(args == menu){
message.reply(`accepted your order for ${menu[args]}!`);
}
menu.json:
{
"menu": ["coffee", "donut", "tea"]
}
I know it sounds a little bit confusing, but I hope you are able to help.
i think that somethin like this gonna work!
var menu = ["coffee", "donut", "tea"];
var args = "Tea";
if(menu.includes(args.toLowerCase())) {
console.log("Order accept " + menu[menu.indexOf(args.toLowerCase())]);
}else {
console.log("Product not found");
}