Haha-Yes/commands/admin/starboard.js

64 lines
1.6 KiB
JavaScript
Raw Normal View History

const { Command } = require('discord-akairo');
const fs = require('fs');
class StarBoardCommand extends Command {
2019-01-02 08:09:45 +01:00
constructor() {
super('starboard', {
aliases: ['starboard'],
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: '👍',
2019-02-14 18:44:21 +01:00
},
{
id: 'count',
type: 'integer',
2019-06-23 03:41:59 +02:00
prompt: {
start: 'How many times should that emote be reacted to enter the shameboard?',
optional: true
},
2020-07-16 09:28:06 +02:00
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: {
2019-11-09 12:04:01 +01:00
content: 'Set starboard to the current channel. --remove to remove the starboard',
2019-09-29 19:35:13 +02:00
usage: '[emote] [minimum number required to enter starboard]',
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 starboardChannel = message.channel.id;
2019-06-23 03:41:59 +02:00
fs.writeFile(`./board/star${message.guild.id}.json`, `{"starboard": "${starboardChannel}", "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 starboard with ${args.emote} with the minimum of ${args.count}`);
2019-06-23 03:41:59 +02:00
} else {
fs.unlink(`./board/star${message.guild.id}.json`, function (err) {
if (err) return message.channel.send('There is no shameboard');
return message.channel.send('Deleted the starboard');
});
}
2019-01-02 08:09:45 +01:00
}
}
module.exports = StarBoardCommand;