Add support for reloading modules(commands) without restarting the bot.

This commit is contained in:
SileNce5k 2021-03-08 20:30:33 +01:00
parent 35d47e4a11
commit acd2e2a502
No known key found for this signature in database
GPG key ID: C507260E7F2583AD
3 changed files with 61 additions and 9 deletions

31
commands/reload.js Normal file
View file

@ -0,0 +1,31 @@
const Discord = require('discord.js');
module.exports = {
name: 'reload',
description: 'Reloads modules.',
admin: true,
execute(message, client) {
let reloadCommands = require("../util/reloadCommands.js")
let beforeSize = client.commands.size;
let sendText;
reloadCommands(client)
if (beforeSize > client.commands.size) {
let difference = beforeSize - client.commands.size;
if (difference == 1)
sendText = `${difference} module was removed and ${client.commands.size} in total were reloaded.`
else
sendText = `${difference} modules were removed and ${client.commands.size} in total were reloaded.`
} else if (beforeSize < client.commands.size) {
let difference = client.commands.size - beforeSize;
if (difference == 1)
sendText = `${difference} module was added and ${client.commands.size} in total were reloaded`
else
sendText = `${difference} modules were added and ${client.commands.size} in total were reloaded`
} else if (beforeSize === client.commands.size) {
sendText = `${client.commands.size} modules were reloaded`
}
message.channel.send(sendText)
}
};