mirror of
https://github.com/Art-Portal/April.git
synced 2025-03-12 16:52:19 +01:00
Added comments and allowed passing null as loadcommand argument
This commit is contained in:
parent
22ec12a1d4
commit
ad698b9653
18
functions.js
18
functions.js
@ -1,15 +1,14 @@
|
||||
const { REST } = require('@discordjs/rest');
|
||||
const { Routes } = require('discord-api-types/v10');
|
||||
const { token, clientId, guildId } = require('./config.json');
|
||||
const { Collection, SlashCommandBuilder } = require('discord.js')
|
||||
const { isBoolean } = require('util')
|
||||
const { Collection, SlashCommandBuilder } = require('discord.js');
|
||||
const fs = require('fs');
|
||||
const rest = new REST({ version: '10' }).setToken(token);
|
||||
|
||||
|
||||
|
||||
function deploy_commands(client, loadcommands) {
|
||||
if (!isBoolean(loadcommands)) throw "type of loadcommands argument needs to be boolean";
|
||||
if (typeof loadcommands !="boolean" && loadcommands != null) throw "loadcommands argument needs to be boolean or null";
|
||||
|
||||
const commands = [];
|
||||
client.commands = new Collection();
|
||||
@ -24,13 +23,18 @@ function deploy_commands(client, loadcommands) {
|
||||
console.log(`${category}/${command.data.name} chargé !`);
|
||||
}
|
||||
}
|
||||
if (loadcommands){
|
||||
if (loadcommands==true){
|
||||
slashCommandLoad(client, commands);
|
||||
console.log("Refreshed slash commands !");
|
||||
}
|
||||
else{//Deletes slash commands
|
||||
slashCommandLoad(client, [])
|
||||
else if(loadcommands==false){//Deletes slash commands
|
||||
slashCommandLoad(client, []);
|
||||
console.log("Deleted slash commands !");
|
||||
}
|
||||
}
|
||||
else{
|
||||
console.log("Kept old commands");
|
||||
}
|
||||
};
|
||||
|
||||
async function slashCommandLoad(client, commands) {
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user