From 4ee80dd9d949da1dbef7d79ab469fb7224adaadd Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Tue, 23 May 2017 01:11:14 +0000 Subject: [PATCH] Starboard --- assets/json/clearsetting.json | 3 ++- commands/settings/settinglist.js | 2 ++ commands/settings/starboard.js | 30 ++++++++++++++++++++++++++++++ html/carbonfeat.html | 1 + html/discordbots.html | 1 + index.js | 18 ++++++++++++++++++ package.json | 2 +- 7 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 commands/settings/starboard.js diff --git a/assets/json/clearsetting.json b/assets/json/clearsetting.json index b1b25b2d..d1f7bb93 100644 --- a/assets/json/clearsetting.json +++ b/assets/json/clearsetting.json @@ -6,5 +6,6 @@ "leaveMsg", "staffRole", "singleRole", - "joinRole" + "joinRole", + "starboard" ] diff --git a/commands/settings/settinglist.js b/commands/settings/settinglist.js index 708401ec..e0697cdf 100644 --- a/commands/settings/settinglist.js +++ b/commands/settings/settinglist.js @@ -18,11 +18,13 @@ module.exports = class SettingListCommand extends Command { const memberLog = msg.guild.settings.get('memberLog', false); const singleRole = msg.guild.settings.get('singleRole', false); const joinRole = msg.guild.settings.get('joinRole', false); + const starboard = msg.guild.settings.get('starboard', false); return msg.say(stripIndents` **Prefix:** ${msg.guild.commandPrefix} **Invite Guard:** ${msg.guild.settings.get('inviteGuard', false)} **Staff Role:** ${staffRole ? (msg.guild.roles.has(staffRole) ? msg.guild.roles.get(staffRole).name : 'Missing') : 'None'} **Mod Channel:** ${modLog ? (msg.guild.channels.has(modLog) ? msg.guild.channels.get(modLog).name : 'Missing') : 'None'} + **Starboard:** ${starboard ? (msg.guild.channels.has(starboard) ? msg.guild.channels.get(starboard).name : 'Missing') : 'None'} **Join Role:** ${joinRole ? (msg.guild.roles.has(joinRole) ? msg.guild.roles.get(joinRole).name : 'Missing') : 'None'} **Member Channel:** ${memberLog ? (msg.guild.channels.has(memberLog) ? msg.guild.channels.get(memberLog).name : 'Missing') : 'None'} **Join Message:** ${msg.guild.settings.get('joinMsg', 'Welcome ! (Default)')} diff --git a/commands/settings/starboard.js b/commands/settings/starboard.js new file mode 100644 index 00000000..8ceede17 --- /dev/null +++ b/commands/settings/starboard.js @@ -0,0 +1,30 @@ +const { Command } = require('discord.js-commando'); + +module.exports = class StarboardCommand extends Command { + constructor(client) { + super(client, { + name: 'starboard', + group: 'settings', + memberName: 'starboard', + description: 'Sets the channel for the starboard.', + guildOnly: true, + args: [ + { + key: 'channel', + prompt: 'What is the channel you want to set as the starboard?', + type: 'channel' + } + ] + }); + } + + hasPermission(msg) { + return msg.member.hasPermission('ADMINISTRATOR'); + } + + run(msg, args) { + const { channel } = args; + msg.guild.settings.set('starboard', channel.id); + return msg.say(`Starboard set to ${channel.name}.`); + } +}; diff --git a/html/carbonfeat.html b/html/carbonfeat.html index c77fc561..d8f22638 100644 --- a/html/carbonfeat.html +++ b/html/carbonfeat.html @@ -62,6 +62,7 @@
  • Customizable Prefix!
  • Member Join/Leave Logging to a Customizable Channel, with a Customizable Message!
  • Customizable Staff Role able to use Mod Commands!
  • +
  • Starboard!
  • Add a role to a user on join!
  • Optional "Single Role Mode" where only one role can use the bot's commands!
  • And so so so much more!
  • diff --git a/html/discordbots.html b/html/discordbots.html index bf07339b..3095a260 100644 --- a/html/discordbots.html +++ b/html/discordbots.html @@ -57,6 +57,7 @@
  • Customizable Prefix!
  • Member Join/Leave Logging to a Customizable Channel, with a Customizable Message!
  • Customizable Staff Role able to use Mod Commands!
  • +
  • Starboard!
  • Add a role to a user on join!
  • Optional "Single Role Mode" where only one role can use the bot's commands!
  • And so so so much more!
  • diff --git a/index.js b/index.js index c2323e0e..0c12389a 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,7 @@ const client = new CommandoClient({ invite: INVITE, unknownCommandResponse: false }); +const { RichEmbed } = require('discord.js'); const path = require('path'); const { carbon, dBots } = require('./structures/Stats'); const SequelizeProvider = require('./providers/Sequelize'); @@ -96,6 +97,23 @@ client.on('message', async (msg) => { } else return; }); +client.on('messageReactionAdd', (reaction, user) => { + if (reaction.emoji.name !== '⭐') return; + if (reaction.count > 1) return; + if (user.bot) return; + const msg = reaction.message; + const channel = msg.guild.channels.get(msg.guild.settings.get('starboard')); + if (!channel) return; + if (!channel.permissionsFor(client.user).has(['SEND_MESSAGES', 'EMBED_LINKS'])) return; + const embed = new RichEmbed() + .setColor(0xFFFF00) + .setAuthor(msg.author.tag, msg.author.displayAvatarURL) + .setDescription(msg.content) + .setImage(msg.attachments.first() ? msg.attachments.first().url : null) + .setFooter(msg.createdAt); + return channel.send({ embed }); +}); + client.dispatcher.addInhibitor(msg => { if (msg.channel.type === 'dm') return false; const role = msg.guild.settings.get('singleRole'); diff --git a/package.json b/package.json index ff33747b..6073a4d5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "19.12.1", + "version": "19.13.0", "description": "A Discord Bot", "main": "shardingmanager.js", "scripts": {