Purgar Comandos

mail@pastecode.io avatar
unknown
javascript
23 days ago
1.2 kB
1
Indexable
Never
client.on("ready", () => {
    console.log(`Entrando como ${client.user.tag}`);

    // Configuración de presencia del bot
    client.user.setPresence({ activities: [{name: 'Reproduciendo'}], status: "online"});

    // Registro de comandos slash en cada servidor
    const guild_ids = client.guilds.cache.map(guild => guild.id);
    const rest = new REST({ version: '10'}).setToken(TOKEN);
    for (const guildId of guild_ids) {
	rest.get(Routes.applicationGuildCommands(CLIENT_ID, guildId))
    .then(commands => {
        console.log('Comandos actuales:', commands);

        // Eliminar comandos
        commands.forEach(command => {
            rest.delete(Routes.applicationGuildCommand(CLIENT_ID, guildId, command.id))
                .then(() => console.log(`Comando ${command.id} eliminado.`))
                .catch(console.error);
        });
    })
    .catch(console.error);
	 }
    
    for (const guildId of guild_ids) {
        rest.put(Routes.applicationGuildCommands(CLIENT_ID, guildId), { body: commands })
            .then(() => console.log('Comandos preparados para el servidor ' + guildId))
            .catch(console.error);
    }
});
Leave a Comment