Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

128
Visualizações
SlashCommands not showing up

I just finished my bot and wanted to invite it to another server to test it out.

However, when I typed / no commands showed up.

When I invited the bot I enabled application.commands so I can use the slashcommands but it still did not work. My bot also has a global slashcommand handler so it should normally work right?

I don't know if the handler code is needed but I'll still add it here in case you do need it:

const { Perms } = require('../Validation/Permissions');
const { Client } = require('discord.js');

/**
 * @param {Client} client
 */

module.exports = async (client, PG, Ascii) => {
    const Table = new Ascii("Command Loaded");

    CommandsArray = [];

    (await PG(`${process.cwd()}/Commands/*/*.js`)).map(async (file) => {
        const command = require(file);

        if(!command.name)
        return Table.addRow(file.split("/")[7], "⛔ FAILED", "Missing a name.")

        if(command.type !== "USER" && !command.description)
        return Table.addRow(command.name, "⛔ FAILED", "Missing a description.")

        if(command.permission){
            if(Perms.includes(command.permission))
            command.defaultPermission = false;
            else
            return Table.addRow(command.name, "⛔ FAILED", "Permission is invalid.")
        }

        client.commands.set(command.name, command);
        CommandsArray.push(command);

        await Table.addRow(command.name, "✅ SUCCESSFUL");
    });

    

    console.log(Table.toString());

    // PERMISSIONS CHECK //

    client.on("ready", async () =>{
        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
1 Respostas
Responde à pergunta

0

You have to register the command first, which is essentially creating the command within Discord. Follow the guide to get it set up. And to clarify, you only register the command once, if that isn't obvious.

You can use Postman to create/edit the commands if you are comfortable with it.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda