forked from Supositware/Haha-Yes
Configurable starboard
This commit is contained in:
parent
d807067acd
commit
fcaa51a555
3 changed files with 47 additions and 41 deletions
|
@ -8,6 +8,18 @@ class shameboardCommand extends Command {
|
|||
category: 'admin',
|
||||
channelRestriction: 'guild',
|
||||
userPermissions: ['MANAGE_CHANNELS'],
|
||||
args: [
|
||||
{
|
||||
id: 'emote',
|
||||
type: 'string',
|
||||
default: '🌟'
|
||||
},
|
||||
{
|
||||
id: 'count',
|
||||
type: 'integer',
|
||||
default: '4'
|
||||
}
|
||||
],
|
||||
description: {
|
||||
content: 'Set shameboard',
|
||||
usage: '[]',
|
||||
|
@ -16,30 +28,16 @@ class shameboardCommand extends Command {
|
|||
});
|
||||
}
|
||||
|
||||
async exec(message) {
|
||||
async exec(message, args) {
|
||||
let shameboardChannel = message.channel.id;
|
||||
|
||||
fs.readFile(`./board/shame${message.guild.id}.json`, 'utf8', function readFileCallback(err, data) {
|
||||
if (err) {
|
||||
fs.writeFile(`./board/shame${message.guild.id}.json`, `{"shameboard": "${shameboardChannel}"}`, function (err) {
|
||||
fs.writeFile(`./board/shame${message.guild.id}.json`, `{"shameboard": "${shameboardChannel}" , "emote": "${args.emote}", "count": "${args.count}"}`, function (err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
let shameboard = JSON.parse(data); //now it an object
|
||||
shameboard['shameboard'] = shameboardChannel;
|
||||
var json = JSON.stringify(shameboard); //convert it back to json
|
||||
fs.writeFile(`./board/shame${message.guild.id}.json`, json, 'utf8', function (err) {
|
||||
if (err) {
|
||||
|
||||
return console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return message.channel.send('This channel have been set as the shameboard');
|
||||
return message.channel.send(`This channel have been set as the shameboard with ${args.emote} with the minium of ${args.count}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,18 @@ class StarBoardCommand extends Command {
|
|||
category: 'admin',
|
||||
channelRestriction: 'guild',
|
||||
userPermissions: ['MANAGE_CHANNELS'],
|
||||
args: [
|
||||
{
|
||||
id: 'emote',
|
||||
type: 'string',
|
||||
default: '🌟'
|
||||
},
|
||||
{
|
||||
id: 'count',
|
||||
type: 'integer',
|
||||
default: '4'
|
||||
}
|
||||
],
|
||||
description: {
|
||||
content: 'Set starboard',
|
||||
usage: '[]',
|
||||
|
@ -16,31 +28,17 @@ class StarBoardCommand extends Command {
|
|||
});
|
||||
}
|
||||
|
||||
async exec(message) {
|
||||
async exec(message, args) {
|
||||
console.log(args);
|
||||
let starboardChannel = message.channel.id;
|
||||
|
||||
fs.readFile(`./board/star${message.guild.id}.json`, 'utf8', function readFileCallback(err, data) {
|
||||
if (err) {
|
||||
console.log('yes');
|
||||
fs.writeFile(`./board/star${message.guild.id}.json`, `{"starboard": "${starboardChannel}"}`, function (err) {
|
||||
fs.writeFile(`./board/star${message.guild.id}.json`, `{"starboard": "${starboardChannel}", "emote": "${args.emote}", "count": "${args.count}"}`, function (err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
let starboard = JSON.parse(data); //now it an object
|
||||
starboard['starboard'] = starboardChannel;
|
||||
var json = JSON.stringify(starboard); //convert it back to json
|
||||
fs.writeFile(`./board/star${message.guild.id}.json`, json, 'utf8', function (err) {
|
||||
if (err) {
|
||||
|
||||
return console.log(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return message.channel.send('This channel have been set as the starboard');
|
||||
return message.channel.send(`This channel have been set as the starboard with ${args.emote} with the minium of ${args.count}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,15 +14,18 @@ class MessageReactionAddListener extends Listener {
|
|||
async exec(reaction) {
|
||||
let messageContent = reaction.message.content;
|
||||
let messageAttachments = reaction.message.attachments.map(u=> `${u.url}`);
|
||||
let starboardChannel = reload(`../../board/star${reaction.message.guild.id}.json`);
|
||||
|
||||
let staremote = starboardChannel['emote'];
|
||||
let starcount = starboardChannel['count'];
|
||||
|
||||
// Starboard
|
||||
if (reaction.emoji.name === '🌟' && reaction.count === 4) {
|
||||
if (reaction.emoji.name == staremote && reaction.count == starcount) {
|
||||
if (messageID.includes(reaction.message.id))
|
||||
return console.log('Message already in starboard!');
|
||||
|
||||
messageID.push(reaction.message.id);
|
||||
|
||||
let starboardChannel = reload(`../../board/star${reaction.message.guild.id}.json`);
|
||||
const channel = this.client.channels.get(starboardChannel['starboard']);
|
||||
|
||||
if (!messageContent)
|
||||
|
@ -37,14 +40,21 @@ class MessageReactionAddListener extends Listener {
|
|||
channel.send({ embed: starEmbed});
|
||||
return channel.send(`in: ${reaction.message.channel} ID: ${reaction.message.id} \n${messageAttachments}`);
|
||||
}
|
||||
|
||||
|
||||
let shameboardChannel = reload(`../../board/shame${reaction.message.guild.id}.json`);
|
||||
|
||||
let shameemote = shameboardChannel['emote'];
|
||||
let shamecount = shameboardChannel['count'];
|
||||
|
||||
|
||||
//Shameboard
|
||||
if (reaction.emoji.name === '✡' && reaction.count === 4) {
|
||||
if (reaction.emoji.name == shameemote && reaction.count == shamecount) {
|
||||
if (messageID.includes(reaction.message.id))
|
||||
return console.log('Message already in starboard!');
|
||||
|
||||
messageID.push(reaction.message.id);
|
||||
|
||||
let shameboardChannel = reload(`../../board/shame${reaction.message.guild.id}.json`);
|
||||
const channel = this.client.channels.get(shameboardChannel['shameboard']);
|
||||
|
||||
if (!messageContent)
|
||||
|
|
Loading…
Reference in a new issue