mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
Add load, unload, and update-env from Hermes
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = class LoadCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'load',
|
||||
aliases: ['load-command', 'load-cmd'],
|
||||
group: 'util',
|
||||
memberName: 'load',
|
||||
description: 'Loads a new command.',
|
||||
details: 'Only the bot owner(s) may use this command.',
|
||||
ownerOnly: true,
|
||||
args: [
|
||||
{
|
||||
key: 'group',
|
||||
prompt: 'Which group is the new command in?',
|
||||
type: 'group'
|
||||
},
|
||||
{
|
||||
key: 'name',
|
||||
prompt: 'What is the new command\'s name?',
|
||||
type: 'string',
|
||||
parse: name => name.toLowerCase()
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg, { group, name }) {
|
||||
let Cmd;
|
||||
try {
|
||||
Cmd = require(path.join(__dirname, '..', group.id, `${name}.js`));
|
||||
} catch {
|
||||
return msg.say('Sorry, I couldn\'t find a command with that name.');
|
||||
}
|
||||
const newCommand = new Cmd(this.client);
|
||||
this.client.registry.registerCommand(newCommand);
|
||||
this.client.registry.commands.get('cloc').cache = null;
|
||||
return msg.say(`Loaded the \`${newCommand.name}\` command.`);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
const Command = require('../../framework/Command');
|
||||
|
||||
module.exports = class UnloadCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'unload',
|
||||
aliases: ['unload-command', 'unload-cmd', 'delete-command', 'delete-cmd'],
|
||||
group: 'util',
|
||||
memberName: 'unload',
|
||||
description: 'Unloads a command.',
|
||||
details: 'Only the bot owner(s) may use this command.',
|
||||
ownerOnly: true,
|
||||
args: [
|
||||
{
|
||||
key: 'command',
|
||||
prompt: 'What is the command\'s name?',
|
||||
type: 'command'
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
run(msg, { command }) {
|
||||
this.client.registry.commands.delete(command.name);
|
||||
this.client.registry.commands.get('cloc').cache = null;
|
||||
return msg.say(`Unloaded the \`${command.name}\` command.`);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
const Command = require('../../framework/Command');
|
||||
const dotenv = require('dotenv');
|
||||
|
||||
module.exports = class UpdateEnvCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'update-env',
|
||||
aliases: ['dotenv', 'update-process-env'],
|
||||
group: 'util',
|
||||
memberName: 'update-env',
|
||||
description: 'Updates the bot\'s environment variables.',
|
||||
details: 'Only the bot owner(s) may use this command.',
|
||||
ownerOnly: true
|
||||
});
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
dotenv.config();
|
||||
return msg.say('Updated environment variables.');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user