2019-05-31 16:26:13 +02:00
|
|
|
const { Command } = require('discord-akairo');
|
2019-07-22 21:58:08 +02:00
|
|
|
const fs = require('fs');
|
2019-05-31 16:26:13 +02:00
|
|
|
|
|
|
|
class unloadCommand extends Command {
|
|
|
|
constructor() {
|
|
|
|
super('unload', {
|
|
|
|
aliases: ['unload'],
|
|
|
|
category: 'owner',
|
|
|
|
ownerOnly: 'true',
|
|
|
|
args: [
|
|
|
|
{
|
|
|
|
id: 'command',
|
|
|
|
type: 'string',
|
2019-07-22 21:58:08 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'noplaceholder',
|
|
|
|
match: 'flag',
|
|
|
|
flag: ['--noplaceholder', '-n']
|
2019-05-31 16:26:13 +02:00
|
|
|
}
|
|
|
|
],
|
|
|
|
description: {
|
2019-07-22 21:58:08 +02:00
|
|
|
content: 'Unload command (use "-n" if you do **not** want a placeholder for this command)',
|
2019-05-31 16:26:13 +02:00
|
|
|
usage: '[command]',
|
|
|
|
examples: ['ping']
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async exec(message, args) {
|
|
|
|
this.handler.remove(args.command);
|
2019-07-22 21:58:08 +02:00
|
|
|
if (!args.noplaceholder) {
|
2019-11-22 12:55:56 +01:00
|
|
|
fs.writeFile(`./${args.command}_unloaded.js`, `const { Command } = require('discord-akairo');
|
2019-07-22 21:58:08 +02:00
|
|
|
|
|
|
|
class ${args.command}Command extends Command {
|
|
|
|
constructor() {
|
|
|
|
super('${args.command}', {
|
|
|
|
aliases: ['${args.command}'],
|
|
|
|
description: {
|
|
|
|
content: 'unloaded command',
|
|
|
|
usage: '[]',
|
|
|
|
examples: ['']
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async exec(message) {
|
|
|
|
return message.channel.send('This command is unloaded, please check back later.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = ${args.command}Command;`,() => {
|
2019-11-22 12:55:56 +01:00
|
|
|
this.handler.load(`${__dirname}/../../${args.command}_unloaded.js`);
|
2019-07-22 21:58:08 +02:00
|
|
|
});
|
|
|
|
}
|
2019-05-31 16:26:13 +02:00
|
|
|
return message.channel.send(`Sucessfully unloaded command ${args.command}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = unloadCommand;
|