Haha-Yes/commands/admin/shameboard.js

66 lines
1.7 KiB
JavaScript
Raw Permalink 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',
2020-03-19 23:24:31 +01:00
channel: '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?',
2020-07-16 09:56:07 +02:00
optional: true
2019-06-23 03:41:59 +02:00
},
2020-07-16 09:56:07 +02:00
default: '👎',
2020-07-16 09:28:06 +02:00
unordered: true
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',
2020-07-16 09:28:06 +02:00
default: '4',
unordered: true
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: {
2019-11-09 12:04:01 +01:00
content: 'Set shameobard in the current channel. --remove to remove the shameboard',
2019-09-29 19:35:13 +02:00
usage: '[emote] [minimum number required to enter shameboard]',
2019-01-02 08:09:45 +01:00
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;