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

105
Views
Problema de comando.ejecutar

Intentaré explicar esto lo mejor que pueda, sin embargo, es un poco confuso. Aquí está mi código para ejecutar un comando de barra.

 client.on('interactionCreate', async interaction => { if (!interaction.isCommand()) return; const command = client.commands.get(interaction.commandName); if (!command) return; try { await command.execute(interaction, Servers, Tickets, client); } catch (error) { console.error(error); await interaction.reply({ embeds: [errorEmbed], ephemeral: true }); } });

Si pongo client justo antes de Servers , me permite usarlo en otros comandos, sin embargo, si lo pongo más tarde, como después de Tickets , no funciona. Esto también sucede cuando muevo Tickets o Servers hasta el final. Ya no puedo usarlos en los comandos. ¿Alguna idea de por qué podría ser esto?

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

0

Si ejecuta command.execute(interaction, Servers, Tickets, client) , el orden de los argumentos debe ser el mismo en cada archivo de comando. Incluso si no necesita las variables Servers o Tickets , si quiere usar el client , es el cuarto argumento.

Sería mejor pasar un solo objeto:

 command.execute({ client, interaction, Servers, Tickets })

Y en sus archivos de comando, desestructura el objeto para elegir los que necesita:

 async execute({ client, interaction }) { // ...
 async execute({ Servers }) { // ...

De esta manera, el orden ya no importa, pero aún deberá actualizar cada archivo de comando con esos corchetes.

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!