Add reload-file command

This commit is contained in:
Dragon Fire
2024-03-31 00:30:51 -04:00
parent 0c633557d9
commit f96ebc5605
2 changed files with 36 additions and 1 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ If you self-host this you're nuts.
22. Run `pm2 start Xiao.js --name xiao` to run the bot.
## Commands
Total: 508
Total: 509
### Utility:
+35
View File
@@ -0,0 +1,35 @@
const Command = require('../../framework/Command');
module.exports = class ReloadFileCommand extends Command {
constructor(client) {
super(client, {
name: 'reload-file',
group: 'util',
memberName: 'reload-file',
description: 'Reloads a file.',
details: 'Only the bot owner(s) may use this command.',
guarded: true,
ownerOnly: true,
args: [
{
key: 'file',
type: 'string',
validate: file => {
try {
require.resolve(`../../${file}`);
return true;
} catch {
return false;
}
}
}
]
});
}
run(msg, { file }) {
delete require.cache[require.resolve(`../../${file}`)];
require(`../../${file}`);
return msg.say(`Reloaded \`${file}\`.`);
}
};