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

576
Views
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 answers
Answer question

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 Report

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 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!