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

577
Vistas
Discord.js v13: Slash commands are duplicated

That seems like some bug or I don't know, but I'm sure this is fixable. All my slash commands are duplicated, first is the newest version of the command, second is some outdated one.

Preview

I'm assuming it is related to slash command registering, so here it is:

const guild = await client.guilds.cache
            .get("836212492769165363")

        guild.commands.set(arrayOfSlashCommands).then((cmd) => {
          const getRoles = (commandName) => {
            const permissions = arrayOfSlashCommands.find(x => x.name === commandName).userPermissions;

            if(!permissions) return null;
            return guild.roles.cache.filter(x => x.permissions.has(permissions) && !x.managed)
          }

          const fullPermissions = cmd.reduce((accumulator, x) => {
            const roles = getRoles(x.name);
            if(!roles) return accumulator;

            const permissions = roles.reduce((a, v) => {
              return [
                ...a,
                {
                  id: v.id, 
                  type: 'ROLE',
                  permission: true,
                },
              ]
            }, [])
            return [
              ...accumulator,
              {
                id: x.id,
                permissions,
              }
            ]
          }, [])
          guild.commands.permissions.set({ fullPermissions }).catch((e) => console.log(e))
        })
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Global and guild commands are not the same.

Explanation


Global and guild commands are 2 different kinds of slash commands stored in different places.
They both have the limit of 100 and have their own ratelimits.

So what's the difference?


  • Global commands are visible to all guilds and users (including DMs).
  • Guild commands on the other hand, is server-specific.

Demonstration


Imagine you have 2 servers, one called A and one called B.

Now, you registered 2 guild commands inside A. Those 2 commands would not appear on B.

But if you register another 2 global commands, this would appear on both servers and including DMs.

What happened to my code then?


You registered both global and guild commands and they both have the same configuration.
That's the reason they all appeared duplicated.

A fix?


There's a way to reset all your guild and global commands.
By using the following code below, it will reset guild commands immediately.
However, you'll have to wait ~1 hour for global commands to update.

    const guild = client.guilds.cache.get("<guild id>");

    // This takes ~1 hour to update
    client.application.commands.set([]);
    // This updates immediately
    guild.commands.set([]);
about 4 years ago · Juan Pablo Isaza Denunciar

0

Try restarting your bot using this code:

client.application.commands.set([])

Or if you have the guild you can do this:

guild.commands.set([])

This might take some time to finish but it will work. It will clear all the slash commands so you can put them back without duplicating. From what I see, you have both Guild commands and application commands

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