Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

100
Vistas
Command.execute issue

I will try to explain this the best I can, however, it is a little confusing. Here is my code for executing a slash command.

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

If I put client right before Servers, it allows me to use it in other commands, however, if I put it later such as after Tickets, it doesn't work. This also happens when I move Tickets or Servers to the end I can no longer use those in the commands. Any ideas on why this could be?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you run command.execute(interaction, Servers, Tickets, client), the order of the arguments must be the same in every command file. Even if you don't need the variables Servers or Tickets, if you want to use the client, it's the fourth argument.

It would be better to pass a single object:

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

And in your command files, destructure the object to pick the ones you need:

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

This way the order no longer matters, but you'll still need to update every command file with those curly brackets.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda