2018-12-30 01:20:24 +01:00
|
|
|
const { Command } = require('discord-akairo');
|
2019-07-08 22:10:14 +02:00
|
|
|
const autoResponseStat = require('../../models').autoresponseStat;
|
2018-12-30 01:20:24 +01:00
|
|
|
|
|
|
|
class autoresponseCommand extends Command {
|
2019-01-02 08:09:45 +01:00
|
|
|
constructor() {
|
|
|
|
super('autoresponse', {
|
|
|
|
aliases: ['autoresponse'],
|
|
|
|
category: 'admin',
|
|
|
|
args: [
|
|
|
|
{
|
2019-07-08 22:10:14 +02:00
|
|
|
id: 'stat',
|
2019-06-23 03:41:59 +02:00
|
|
|
type: 'string',
|
|
|
|
prompt: {
|
|
|
|
start: 'Do you want to **enable** or **disable** auto response?',
|
|
|
|
}
|
2019-01-02 08:09:45 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'all',
|
|
|
|
type: 'string'
|
|
|
|
}
|
|
|
|
],
|
2019-01-12 17:00:36 +01:00
|
|
|
userPermissions: ['MANAGE_MESSAGES'],
|
2019-01-02 08:09:45 +01:00
|
|
|
channelRestriction: 'guild',
|
|
|
|
description: {
|
|
|
|
content: 'enable/disable autoresponse',
|
|
|
|
usage: '[enable/disable] (optional) [all]',
|
|
|
|
examples: ['enable all']
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2018-10-19 23:39:42 +02:00
|
|
|
|
2019-01-02 08:09:45 +01:00
|
|
|
async exec(message, args) {
|
2019-07-23 21:26:41 +02:00
|
|
|
if (args.stat.toLowerCase() == 'enable' || args.stat.toLowerCase() == 'disable') {
|
2019-07-08 22:10:14 +02:00
|
|
|
const autoresponseStat = await autoResponseStat.findOne({where: {serverID: message.guild.id}});
|
2018-11-20 19:33:04 +01:00
|
|
|
|
2019-07-08 22:10:14 +02:00
|
|
|
if (!autoresponseStat) {
|
|
|
|
const body = {serverID: message.guild.id, stat: args.stat};
|
|
|
|
autoResponseStat.create(body);
|
2019-07-23 21:26:41 +02:00
|
|
|
return message.channel.send(`Autoresponse have been ${args.stat}d`);
|
2019-07-08 22:10:14 +02:00
|
|
|
} else {
|
|
|
|
const body = {serverID: message.guild.id, stat: args.stat};
|
|
|
|
autoResponseStat.update(body, {where: {serverID: message.guild.id}});
|
2019-07-23 21:26:41 +02:00
|
|
|
return message.channel.send(`Autoresponse have been ${args.stat}d`);
|
2019-03-03 23:12:02 +01:00
|
|
|
}
|
2019-01-02 08:09:45 +01:00
|
|
|
}
|
|
|
|
}
|
2019-01-02 04:35:34 +01:00
|
|
|
}
|
2018-12-30 01:20:24 +01:00
|
|
|
module.exports = autoresponseCommand;
|