mirror of
https://github.com/Art-Portal/April.git
synced 2025-03-13 17:22:21 +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 { REST } = require('@discordjs/rest');
|
||||||
const { Routes } = require('discord-api-types/v10');
|
const { Routes } = require('discord-api-types/v10');
|
||||||
const { token, clientId, guildId } = require('./config.json');
|
const { token, clientId, guildId } = require('./config.json');
|
||||||
const { Collection, SlashCommandBuilder } = require('discord.js')
|
const { Collection, SlashCommandBuilder } = require('discord.js');
|
||||||
const { isBoolean } = require('util')
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const rest = new REST({ version: '10' }).setToken(token);
|
const rest = new REST({ version: '10' }).setToken(token);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function deploy_commands(client, loadcommands) {
|
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 = [];
|
const commands = [];
|
||||||
client.commands = new Collection();
|
client.commands = new Collection();
|
||||||
@ -24,13 +23,18 @@ function deploy_commands(client, loadcommands) {
|
|||||||
console.log(`${category}/${command.data.name} chargé !`);
|
console.log(`${category}/${command.data.name} chargé !`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (loadcommands){
|
if (loadcommands==true){
|
||||||
slashCommandLoad(client, commands);
|
slashCommandLoad(client, commands);
|
||||||
|
console.log("Refreshed slash commands !");
|
||||||
}
|
}
|
||||||
else{//Deletes slash commands
|
else if(loadcommands==false){//Deletes slash commands
|
||||||
slashCommandLoad(client, [])
|
slashCommandLoad(client, []);
|
||||||
|
console.log("Deleted slash commands !");
|
||||||
}
|
}
|
||||||
}
|
else{
|
||||||
|
console.log("Kept old commands");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
async function slashCommandLoad(client, commands) {
|
async function slashCommandLoad(client, commands) {
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user