Haha-Yes/commands/admin/autoresponse.js

45 lines
1.3 KiB
JavaScript
Raw Normal View History

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
}
],
2019-11-09 12:04:01 +01:00
clientPermissions: ['SEND_MESSAGES'],
2019-01-12 17:00:36 +01:00
userPermissions: ['MANAGE_MESSAGES'],
2020-03-19 23:24:31 +01:00
channel: 'guild',
2019-01-02 08:09:45 +01:00
description: {
content: 'enable/disable autoresponse',
2020-03-05 21:40:16 +01:00
usage: '[enable/disable]',
examples: ['enable']
2019-01-02 08:09:45 +01:00
}
});
}
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-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;