Haha-Yes/commands/admin/shameboard.js

64 lines
1.5 KiB
JavaScript
Raw Normal View History

const { Command } = require('discord-akairo');
const fs = require('fs');
2019-01-01 09:42:54 +01:00
class shameboardCommand extends Command {
2019-01-02 08:09:45 +01:00
constructor() {
super('shameboard', {
aliases: ['shameboard'],
category: 'admin',
channelRestriction: 'guild',
2019-01-12 17:00:36 +01:00
userPermissions: ['MANAGE_CHANNELS'],
2019-02-14 18:44:21 +01:00
args: [
{
id: 'emote',
type: 'string',
2019-06-23 03:41:59 +02:00
prompt: {
start: 'What emote should be used to enter the shameboard?',
optional: true
},
2019-02-14 18:48:02 +01:00
default: '✡'
2019-02-14 18:44:21 +01:00
},
{
id: 'count',
2019-06-23 03:41:59 +02:00
prompt: {
start: 'How many times should that emote be reacted to enter the shameboard?',
optional: true
},
2019-02-14 18:44:21 +01:00
type: 'integer',
default: '4'
2019-06-23 03:41:59 +02:00
},
{
id: 'remove',
match: 'flag',
flag: '--remove'
2019-02-14 18:44:21 +01:00
}
],
2019-01-02 08:09:45 +01:00
description: {
content: 'Set shameboard',
usage: '[]',
examples: ['']
}
});
}
2019-02-14 18:44:21 +01:00
async exec(message, args) {
2019-06-23 03:41:59 +02:00
if (!args.remove) {
let shameboardChannel = message.channel.id;
2019-06-23 03:41:59 +02:00
fs.writeFile(`./board/shame${message.guild.id}.json`, `{"shameboard": "${shameboardChannel}" , "emote": "${args.emote}", "count": "${args.count}"}`, function (err) {
if (err) {
console.log(err);
}
});
2019-06-28 03:50:12 +02:00
return message.channel.send(`This channel have been set as the shameboard with ${args.emote} with the minimum of ${args.count}`);
2019-06-23 03:41:59 +02:00
} else {
fs.unlink(`./board/shame${message.guild.id}.json`, function (err) {
if (err) return message.channel.send('There is no shameboard');
return message.channel.send('Deleted the shameboard');
});
}
2019-01-02 08:09:45 +01:00
}
}
2019-01-01 09:42:54 +01:00
module.exports = shameboardCommand;