The helper bot for LHT https://lhtranslation.net
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Senko/bot/runtime/commands/dev/reload.js

33 lines
1.7 KiB

const Discord = require('discord.js');
const fs = require('fs');
const chalk = require('chalk');
const ora = require('ora');
const {EmbedBuilder} = require("discord.js");
module.exports = {
name: "reload",
aliases: ['relog', 'rel', 'refresh'],
help: new EmbedBuilder()
.setTitle("Help -> System Reloading")
.setDescription("Reloads the system extensions by refreshing all command and event files into client without terminating the node process.")
.addFields(
[{name: "Syntax", value: "`reload [log]`. Adding 'log' will log to the console as though the bot were in startup."},
{name: "Notice", value: "This command is only available to developers."}]
),
category: 'Developer',
info: "Refresh all client commands and events and clear most of the require cache.",
syntax: '`reload`',
async execute(client, message, args, cmd) {
if (!client.config.developers.has(message.author.id)) {return message.channel.send(`You must be a ${client.config.bot.name} developer in order to do this!`);}
if (!args.length) {
let timer = new Date().getTime();
let commands = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
let dirSet = new Map();
fs.readdirSync('./commands').filter(file => !file.includes('.')).forEach(dir => fs.readdirSync(`./commands/${dir}`).filter(file => file.endsWith('.js')).forEach(x => {commands.push(x); dirSet.set(x, dir)}));
client.warn(`${chalk.gray('Reload:')} ${chalk.white('All commands and events are being reloaded!')}\``);
client.log(`Developer ${message.author.username} initiated the system refresh`, {color: 'ff4fd0', source: "info"}, 0, 1);
}
}
};