mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Add reload-file command
This commit is contained in:
@@ -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:
|
||||
|
||||
|
||||
@@ -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}\`.`);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user