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

69
Views
¿Hay alguna forma de comparar los argumentos de los mensajes con un archivo .json?

tengo este codigo:

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

Y lo que quiero que haga:

  • Comprobar argumentos
  • Compare si los argumentos son alguno de los elementos del menú
  • Dar una respuesta basada en el elemento.
    Me gusta:
 if(args == menu){ message.reply(`accepted your order for ${menu[args]}!`); }

menú.json:

 { "menu": ["coffee", "donut", "tea"] }

Sé que suena un poco confuso, pero espero que puedas ayudar.

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

0

¡Creo que algo como esto va a funcionar!

 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!