Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

65
Views
Is there any way I can compare message arguments to a .json file

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:

  • Check args
  • Compare if args are any of the menu elements
  • Give an answer based on the element
    Like:
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.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!