From ed7b4cb5e18b9ab63e6434830b70857d8dda9573 Mon Sep 17 00:00:00 2001 From: Daniel Odendahl Jr Date: Fri, 23 Mar 2018 11:10:59 +0000 Subject: [PATCH] littlelimedragon, union types --- assets/json/cards-against-humanity.json | 6 +++--- commands/image-edit/contrast.js | 2 +- commands/image-edit/demotivational-poster.js | 2 +- commands/image-edit/distort.js | 2 +- commands/image-edit/glitch.js | 2 +- commands/image-edit/greyscale.js | 2 +- commands/image-edit/ifunny.js | 2 +- commands/image-edit/invert.js | 2 +- commands/image-edit/sepia.js | 2 +- commands/image-edit/silhouette.js | 2 +- commands/image-edit/tint.js | 2 +- commands/util/donate.js | 2 +- commands/util/info.js | 2 +- package.json | 12 ++++++------ types/avatar.js | 18 ++++++++++++++++++ types/image.js | 13 +------------ 16 files changed, 40 insertions(+), 33 deletions(-) create mode 100644 types/avatar.js diff --git a/assets/json/cards-against-humanity.json b/assets/json/cards-against-humanity.json index d93ac9d5..29ee4ef6 100644 --- a/assets/json/cards-against-humanity.json +++ b/assets/json/cards-against-humanity.json @@ -3218,9 +3218,9 @@ "An icy handjob from an Edmonton hooker.", "eat pant.", "", - "dragonfire535.", - "XiaoBot.", - "XiaoBot's public source code.", + "littlelimedragon.", + "Xiao.", + "Xiao's public source code.", "Discord." ] } diff --git a/commands/image-edit/contrast.js b/commands/image-edit/contrast.js index 6e350b89..ced4d54e 100644 --- a/commands/image-edit/contrast.js +++ b/commands/image-edit/contrast.js @@ -19,7 +19,7 @@ module.exports = class ContrastCommand extends Command { { key: 'image', prompt: 'What image would you like to edit?', - type: 'image', + type: 'image|avatar', default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 }) } ] diff --git a/commands/image-edit/demotivational-poster.js b/commands/image-edit/demotivational-poster.js index 53cefee6..56135b1e 100644 --- a/commands/image-edit/demotivational-poster.js +++ b/commands/image-edit/demotivational-poster.js @@ -35,7 +35,7 @@ module.exports = class DemotivationalPosterCommand extends Command { { key: 'image', prompt: 'What image would you like to edit?', - type: 'image', + type: 'image|avatar', default: msg => msg.author.displayAvatarURL({ format: 'png', size: 1024 }) } ] diff --git a/commands/image-edit/distort.js b/commands/image-edit/distort.js index 60a58a93..58193e36 100644 --- a/commands/image-edit/distort.js +++ b/commands/image-edit/distort.js @@ -25,7 +25,7 @@ module.exports = class DistortCommand extends Command { { key: 'image', prompt: 'What image would you like to edit?', - type: 'image', + type: 'image|avatar', default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 }) } ] diff --git a/commands/image-edit/glitch.js b/commands/image-edit/glitch.js index 4a862260..c62330d0 100644 --- a/commands/image-edit/glitch.js +++ b/commands/image-edit/glitch.js @@ -19,7 +19,7 @@ module.exports = class GlitchCommand extends Command { { key: 'image', prompt: 'What image would you like to edit?', - type: 'image', + type: 'image|avatar', default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 }) } ] diff --git a/commands/image-edit/greyscale.js b/commands/image-edit/greyscale.js index e1a2e4f0..3ce173bb 100644 --- a/commands/image-edit/greyscale.js +++ b/commands/image-edit/greyscale.js @@ -20,7 +20,7 @@ module.exports = class GreyscaleCommand extends Command { { key: 'image', prompt: 'What image would you like to edit?', - type: 'image', + type: 'image|avatar', default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 }) } ] diff --git a/commands/image-edit/ifunny.js b/commands/image-edit/ifunny.js index 6d3a5cbe..54b55c58 100644 --- a/commands/image-edit/ifunny.js +++ b/commands/image-edit/ifunny.js @@ -19,7 +19,7 @@ module.exports = class IfunnyCommand extends Command { { key: 'image', prompt: 'What image would you like to edit?', - type: 'image', + type: 'image|avatar', default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 }) } ] diff --git a/commands/image-edit/invert.js b/commands/image-edit/invert.js index 84352cb9..c46f954a 100644 --- a/commands/image-edit/invert.js +++ b/commands/image-edit/invert.js @@ -19,7 +19,7 @@ module.exports = class InvertCommand extends Command { { key: 'image', prompt: 'What image would you like to edit?', - type: 'image', + type: 'image|avatar', default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 }) } ] diff --git a/commands/image-edit/sepia.js b/commands/image-edit/sepia.js index 873aa3e3..13c1f4b8 100644 --- a/commands/image-edit/sepia.js +++ b/commands/image-edit/sepia.js @@ -19,7 +19,7 @@ module.exports = class SepiaCommand extends Command { { key: 'image', prompt: 'What image would you like to edit?', - type: 'image', + type: 'image|avatar', default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 }) } ] diff --git a/commands/image-edit/silhouette.js b/commands/image-edit/silhouette.js index 80c95300..eff6c1cc 100644 --- a/commands/image-edit/silhouette.js +++ b/commands/image-edit/silhouette.js @@ -19,7 +19,7 @@ module.exports = class SilhouetteCommand extends Command { { key: 'image', prompt: 'What image would you like to edit?', - type: 'image', + type: 'image|avatar', default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 }) } ] diff --git a/commands/image-edit/tint.js b/commands/image-edit/tint.js index ec0042e7..a821ccb6 100644 --- a/commands/image-edit/tint.js +++ b/commands/image-edit/tint.js @@ -25,7 +25,7 @@ module.exports = class TintCommand extends Command { { key: 'image', prompt: 'What image would you like to edit?', - type: 'image', + type: 'image|avatar', default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 }) } ] diff --git a/commands/util/donate.js b/commands/util/donate.js index 34dcdf63..a2f87a0d 100644 --- a/commands/util/donate.js +++ b/commands/util/donate.js @@ -16,7 +16,7 @@ module.exports = class DonateCommand extends Command { run(msg) { return msg.say(stripIndents` Contribute to XiaoBot development! - + `); } diff --git a/commands/util/info.js b/commands/util/info.js index 134517cd..efe88487 100644 --- a/commands/util/info.js +++ b/commands/util/info.js @@ -19,7 +19,7 @@ module.exports = class InfoCommand extends Command { run(msg) { const embed = new MessageEmbed() .setColor(0x00AE86) - .setFooter('©2017-2018 dragonfire535#8081') + .setFooter('©2017-2018 littlelimedragon#8081') .addField('❯ Servers', this.client.guilds.size, true) .addField('❯ Shards', diff --git a/package.json b/package.json index 29cf584c..a405bc76 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "70.0.0", + "version": "70.0.1", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { @@ -10,7 +10,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/dragonfire535/xiao.git" + "url": "git+https://github.com/littlelimedragon/xiao.git" }, "keywords": [ "bot", @@ -21,12 +21,12 @@ "discord-js", "discord-js-commando" ], - "author": "dragonfire535 ", + "author": "littlelimedragon ", "license": "GPL-3.0", "bugs": { - "url": "https://github.com/dragonfire535/xiao/issues" + "url": "https://github.com/littlelimedragon/xiao/issues" }, - "homepage": "https://github.com/dragonfire535/xiao#readme", + "homepage": "https://github.com/littlelimedragon/xiao#readme", "engines": { "node": ">=8.0.0" }, @@ -48,7 +48,7 @@ "zlib-sync": "^0.1.4" }, "devDependencies": { - "eslint": "^4.18.1", + "eslint": "^4.19.0", "eslint-config-aqua": "^2.0.1", "eslint-plugin-json": "^1.2.0" }, diff --git a/types/avatar.js b/types/avatar.js new file mode 100644 index 00000000..017f269f --- /dev/null +++ b/types/avatar.js @@ -0,0 +1,18 @@ +const { ArgumentType } = require('discord.js-commando'); + +class AvatarArgumentType extends ArgumentType { + constructor(client) { + super(client, 'avatar'); + } + + validate(value, msg, arg) { + return this.client.types.get('user').validate(value, msg, arg); + } + + async parse(value, msg, arg) { + const user = await this.client.types.get('user').parse(value, msg, arg); + return user.displayAvatarURL({ format: 'png', size: 512 }); + } +} + +module.exports = AvatarArgumentType; diff --git a/types/image.js b/types/image.js index 3b4721a0..e49a3198 100644 --- a/types/image.js +++ b/types/image.js @@ -7,27 +7,16 @@ class ImageArgumentType extends ArgumentType { async validate(value, msg) { const attachment = msg.attachments.first(); - if (!attachment) { - const valid = await this.client.registry.types.get('user').validate(value, msg); - return valid; - } - if (!attachment.height || !attachment.width) return false; + if (!attachment || !attachment.height || !attachment.width) return false; if (attachment.size > 8e+6) return 'Please provide an image under 8 MB.'; return true; } parse(value, msg) { - if (!msg.attachments.size) { - return this.client.registry.types.get('user').parse(value, msg).displayAvatarURL({ - format: 'png', - size: 512 - }); - } return msg.attachments.first().url; } isEmpty(value, msg) { - if (!msg.attachments.size) return !value; return !msg.attachments.size; } }