diff --git a/XiaoBot.js b/XiaoBot.js index ee555c14..234f471a 100644 --- a/XiaoBot.js +++ b/XiaoBot.js @@ -80,7 +80,6 @@ client.on('message', async (msg) => { client.on('messageReactionAdd', (reaction, user) => { if (reaction.emoji.name !== '⭐') return; - if (reaction.count > 1) return; const msg = reaction.message; const channel = msg.guild.channels.get(msg.guild.settings.get('starboard')); if (!channel) return; @@ -94,7 +93,7 @@ client.on('messageReactionAdd', (reaction, user) => { client.on('guildMemberAdd', (member) => { const role = member.guild.roles.get(member.guild.settings.get('joinRole')); - if (member.guild.me.hasPermission('MANAGE_ROLES') && role) + if (member.guild.me.hasPermission('MANAGE_ROLES') && role) member.addRole(role).catch(() => null); const channel = member.guild.channels.get(member.guild.settings.get('memberLog')); if (!channel) return; diff --git a/assets/images/challenger.png b/assets/images/challenger.png new file mode 100644 index 00000000..769204be Binary files /dev/null and b/assets/images/challenger.png differ diff --git a/commands/avataredit/challenger.js b/commands/avataredit/challenger.js new file mode 100644 index 00000000..5129d45f --- /dev/null +++ b/commands/avataredit/challenger.js @@ -0,0 +1,58 @@ +const { Command } = require('discord.js-commando'); +const Canvas = require('canvas'); +const snekfetch = require('snekfetch'); +const { promisifyAll } = require('tsubaki'); +const fs = promisifyAll(require('fs')); +const path = require('path'); + +module.exports = class ChallengerCommand extends Command { + constructor(client) { + super(client, { + name: 'challenger', + group: 'avataredit', + memberName: 'challenger', + description: 'A new foe has appeared.', + throttling: { + usages: 1, + duration: 15 + }, + args: [ + { + key: 'user', + prompt: 'Which user would you like to edit the avatar of?', + type: 'user' + } + ] + }); + } + + async run(msg, args) { + if (msg.channel.type !== 'dm') + if (!msg.channel.permissionsFor(this.client.user).has('ATTACH_FILES')) + return msg.say('This Command requires the `Attach Files` Permission.'); + const { user } = args; + const avatarURL = user.avatarURL('png', 256); + if (!avatarURL) return msg.say('This user has no avatar.'); + try { + const Image = Canvas.Image; + const canvas = new Canvas(500, 500); + const ctx = canvas.getContext('2d'); + const base = new Image(); + const avatar = new Image(); + const generate = () => { + ctx.fillStyle = '#ff0028'; + ctx.fillRect(0, 0, 500, 500); + ctx.drawImage(avatar, 226, 155, 200, 200); + ctx.drawImage(base, 0, 0); + }; + base.src = await fs.readFileAsync(path.join(__dirname, '..', '..', 'assets', 'images', 'challenger.png')); + const { body } = await snekfetch.get(avatarURL); + avatar.src = body; + generate(); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'challenger.png' }] }) + .catch(err => msg.say(`${err.name}: ${err.message}`)); + } catch (err) { + return msg.say(`${err.name}: ${err.message}`); + } + } +}; diff --git a/commands/moderation/ban.js b/commands/moderation/ban.js index 565043fe..be252d64 100644 --- a/commands/moderation/ban.js +++ b/commands/moderation/ban.js @@ -29,7 +29,7 @@ module.exports = class BanCommand extends Command { ] }); } - + hasPermission(msg) { return msg.member.hasPermission('BAN_MEMBERS') || msg.member.roles.has(msg.guild.settings.get('staffRole')); } diff --git a/commands/moderation/kick.js b/commands/moderation/kick.js index ef75cbe0..eb3ff2a1 100644 --- a/commands/moderation/kick.js +++ b/commands/moderation/kick.js @@ -28,7 +28,7 @@ module.exports = class KickCommand extends Command { ] }); } - + hasPermission(msg) { return msg.member.hasPermission('KICK_MEMBERS') || msg.member.roles.has(msg.guild.settings.get('staffRole')); } diff --git a/commands/moderation/lockdown.js b/commands/moderation/lockdown.js index 3eb60169..61267382 100644 --- a/commands/moderation/lockdown.js +++ b/commands/moderation/lockdown.js @@ -24,7 +24,7 @@ module.exports = class LockdownCommand extends Command { ] }); } - + hasPermission(msg) { return msg.member.hasPermission('ADMINISTRATOR') || msg.member.roles.has(msg.guild.settings.get('staffRole')); } diff --git a/commands/moderation/prune.js b/commands/moderation/prune.js index a3b80ffd..4ee48954 100644 --- a/commands/moderation/prune.js +++ b/commands/moderation/prune.js @@ -26,7 +26,7 @@ module.exports = class PruneCommand extends Command { ] }); } - + hasPermission(msg) { return msg.member.hasPermission('MANAGE_MESSAGES') || msg.member.roles.has(msg.guild.settings.get('staffRole')); } diff --git a/commands/moderation/softban.js b/commands/moderation/softban.js index 922a1d05..d88f6f7d 100644 --- a/commands/moderation/softban.js +++ b/commands/moderation/softban.js @@ -29,7 +29,7 @@ module.exports = class SoftbanCommand extends Command { ] }); } - + hasPermission(msg) { return msg.member.hasPermission('KICK_MEMBERS') || msg.member.roles.has(msg.guild.settings.get('staffRole')); } diff --git a/commands/moderation/unban.js b/commands/moderation/unban.js index 3f190b9c..5abe1e33 100644 --- a/commands/moderation/unban.js +++ b/commands/moderation/unban.js @@ -29,7 +29,7 @@ module.exports = class UnbanCommand extends Command { ] }); } - + hasPermission(msg) { return msg.member.hasPermission('BAN_MEMBERS') || msg.member.roles.has(msg.guild.settings.get('staffRole')); } diff --git a/commands/moderation/warn.js b/commands/moderation/warn.js index 3801c458..ce96644b 100644 --- a/commands/moderation/warn.js +++ b/commands/moderation/warn.js @@ -28,7 +28,7 @@ module.exports = class WarnCommand extends Command { ] }); } - + hasPermission(msg) { return msg.member.hasPermission('KICK_MEMBERS') || msg.member.roles.has(msg.guild.settings.get('staffRole')); } diff --git a/commands/random/star.js b/commands/random/star.js index c6880847..3fba1589 100644 --- a/commands/random/star.js +++ b/commands/random/star.js @@ -17,12 +17,15 @@ module.exports = class StarCommand extends Command { } ] }); + + this.starred = []; } async run(msg, args, reaction) { const { id } = args; const channel = msg.guild.channels.get(msg.guild.settings.get('starboard')); if (!channel || !channel.permissionsFor(this.client.user).has('EMBED_LINKS')) return null; + if (this.starred.includes(id)) return null; try { const message = await msg.channel.fetchMessage(id); if (!reaction && msg.author.id === message.author.id) @@ -33,6 +36,7 @@ module.exports = class StarCommand extends Command { .setDescription(message.content) .setImage(message.attachments.first() ? message.attachments.first().url : null) .setFooter(moment(message.createdTimestamp).format('MMMM Do YYYY h:mm:ss A')); + this.starred.push(id); await channel.send({ embed }); return null; } catch (err) { diff --git a/commands/settings/clear-setting.js b/commands/settings/clear-setting.js index d95fbee2..8776e5ec 100644 --- a/commands/settings/clear-setting.js +++ b/commands/settings/clear-setting.js @@ -22,7 +22,7 @@ module.exports = class ClearSettingCommand extends Command { ] }); } - + hasPermission(msg) { return msg.member.hasPermission('ADMINISTRATOR'); } diff --git a/commands/settings/invite-guard.js b/commands/settings/invite-guard.js index d6819c68..0ffeb078 100644 --- a/commands/settings/invite-guard.js +++ b/commands/settings/invite-guard.js @@ -10,7 +10,7 @@ module.exports = class InviteGuardCommand extends Command { guildOnly: true }); } - + hasPermission(msg) { return msg.member.hasPermission('ADMINISTRATOR'); } diff --git a/commands/settings/join-role.js b/commands/settings/join-role.js index 2f9cc877..56eef6bd 100644 --- a/commands/settings/join-role.js +++ b/commands/settings/join-role.js @@ -17,7 +17,7 @@ module.exports = class JoinRoleCommand extends Command { ] }); } - + hasPermission(msg) { return msg.member.hasPermission('ADMINISTRATOR'); } diff --git a/commands/settings/member-channel.js b/commands/settings/member-channel.js index 40fb0a0b..e456dd7a 100644 --- a/commands/settings/member-channel.js +++ b/commands/settings/member-channel.js @@ -17,7 +17,7 @@ module.exports = class MemberLogCommand extends Command { ] }); } - + hasPermission(msg) { return msg.member.hasPermission('ADMINISTRATOR'); } diff --git a/commands/settings/mod-channel.js b/commands/settings/mod-channel.js index 5714cb9e..67941ad5 100644 --- a/commands/settings/mod-channel.js +++ b/commands/settings/mod-channel.js @@ -17,7 +17,7 @@ module.exports = class ModChannelCommand extends Command { ] }); } - + hasPermission(msg) { return msg.member.hasPermission('ADMINISTRATOR'); } diff --git a/commands/settings/single-role.js b/commands/settings/single-role.js index d96e5c39..8bd2a369 100644 --- a/commands/settings/single-role.js +++ b/commands/settings/single-role.js @@ -17,7 +17,7 @@ module.exports = class SingleRoleCommand extends Command { ] }); } - + hasPermission(msg) { return msg.member.hasPermission('ADMINISTRATOR'); } diff --git a/commands/settings/staff-role.js b/commands/settings/staff-role.js index db69d3f6..0b268bff 100644 --- a/commands/settings/staff-role.js +++ b/commands/settings/staff-role.js @@ -17,7 +17,7 @@ module.exports = class StaffRoleCommand extends Command { ] }); } - + hasPermission(msg) { return msg.member.hasPermission('ADMINISTRATOR'); } diff --git a/commands/settings/starboard.js b/commands/settings/starboard.js index 8ceede17..93995104 100644 --- a/commands/settings/starboard.js +++ b/commands/settings/starboard.js @@ -17,7 +17,7 @@ module.exports = class StarboardCommand extends Command { ] }); } - + hasPermission(msg) { return msg.member.hasPermission('ADMINISTRATOR'); } diff --git a/commands/textedit/cow-say.js b/commands/textedit/cow-say.js index fee178cd..a0046cb3 100644 --- a/commands/textedit/cow-say.js +++ b/commands/textedit/cow-say.js @@ -24,7 +24,7 @@ module.exports = class CowsayCommand extends Command { run(msg, args) { const { text } = args; - return msg.code(null, + return msg.code(null, stripIndent` < ${text} > \\ ^__^ diff --git a/commands/textedit/webhook.js b/commands/textedit/webhook.js index 56f38890..c6ddd636 100644 --- a/commands/textedit/webhook.js +++ b/commands/textedit/webhook.js @@ -20,7 +20,7 @@ module.exports = class WebhookCommand extends Command { ] }); } - + hasPermission(msg) { return this.client.isOwner(msg.author); } diff --git a/package.json b/package.json index 396ff73d..b04b1c21 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiaobot", - "version": "21.2.4", + "version": "21.2.5", "description": "A Discord Bot", "main": "Shard.js", "scripts": { diff --git a/structures/CommandoClient.js b/structures/CommandoClient.js index 3b7fe81d..d2671897 100644 --- a/structures/CommandoClient.js +++ b/structures/CommandoClient.js @@ -5,7 +5,7 @@ class CommandoClient extends Client { constructor(options) { super(options); this.database = Database.db; - + Database.start(); } }