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

259
Vistas
Discord.js V13 Updating slash commands cache on role permissions update

As the title suggests, I am trying to figure out a way to update my slash commands cache on role permissions updates, because as right now whenever I make changes to role permissions, the slash commands cache only recognises the roles permission when from when it initially starts up, and I'd like to change this.

If anyone could lend a helping hand, I'd really appreciate it!

module.exports = {
    new: 'roleUpdate',
    async execute(oldRole, newRole) {
        if (oldRole.permissions !== newRole.permissions) {
            client.guilds.cache.forEach((g) => {
                g.commands.set(CommandsArray).then(async (command) => {
                    const Roles = (commandName) => {
                        const cmdPerms = CommandsArray.find((c) => c.name === commandName).permission;
                        if (!cmdPerms) return null;

                        return g.roles.cache.filter((r) => r.permissions.has(cmdPerms) && !r.managed).first(10);
                    }

                    const fullPermissions = command.reduce((accumulator, r) => {
                        const roles = Roles(r.name);
                        if (!roles) return accumulator;

                        const permissions = roles.reduce((a, r) => {
                            return [...a, { id: r.id, type: "ROLE", permission: true }]
                        }, [])
                        return [...accumulator, { id: r.id, permissions }]
                    }, [])

                    await g.commands.permissions.set({ fullPermissions });
                });
            });
    
        }
    }
}
about 4 years ago · Juan Pablo Isaza
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