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

129
Views
Pase el archivo de configuración del bot para que sea accesible globalmente desde el Cliente

Quiero pasar el archivo de configuración de mi bot ( config.json ) al cliente del bot para poder obtener, por ejemplo, el ID del propietario del bot en lugar de especificarlo en cada comando al que solo quiero que acceda el propietario del bot, o la incrustación texto de pie de página, ejemplo:

 async execute(client, message, args, footerTxt) { if (message.author.id == BotOwnerId) {

Quiero ser capaz de que sea

 async execute(client, message, args){ if (message.author.id == client.config.ownerID) {

He intentado ejecutarlo a través del comando ejecutar

 try { await client.commands.get(command).execute(client, message, args, footerTxt, config); } catch (error) {

lo que resultó en

 TypeError: Cannot read properties of undefined (reading 'ownerID') at Object.execute
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

config.json

 { "ownerID": "XXXXXXXXXXX", "someOtherStuff": [], "someMoreStuff": { "id": 1, "name": "Test" } }

index (asumiendo que config.json está en la misma carpeta)

 const config = require('./config.json') await client.commands.get(command).execute(client, message, args, footerTxt, config);

cmd:

 if (message.author.id == config.ownerID) {

¿Por qué no simplemente requerir el archivo de configuración en el índice y pasarlo a través de los argumentos al comando? ¿O lo requieren en los comandos? Como quieras, pero debería funcionar.

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!