diff --git a/README.md b/README.md index 723f3395..47b0dab1 100644 --- a/README.md +++ b/README.md @@ -243,7 +243,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 524 +Total: 525 ### Utility: @@ -511,6 +511,7 @@ Total: 524 * **face:** Determines the race, gender, and age of a face. * **gender:** Determines the gender of a name. * **has-transparency:** Determines if an image has transparency in it. +* **image-size:** Determines the size of an image. * **read-qr-code:** Reads a QR Code. * **scrabble-score:** Responds with the scrabble score of a word. * **severe-toxicity:** Determines the toxicity of text, but less sensitive to milder language. diff --git a/commands/analyze/image-size.js b/commands/analyze/image-size.js new file mode 100644 index 00000000..4a129228 --- /dev/null +++ b/commands/analyze/image-size.js @@ -0,0 +1,37 @@ +const Command = require('../../structures/Command'); +const { loadImage } = require('canvas'); +const request = require('node-superfetch'); + +module.exports = class ImageSizeCommand extends Command { + constructor(client) { + super(client, { + name: 'image-size', + aliases: ['img-size', 'size', 'dimensions', 'image-dimensions', 'img-dimensions'], + group: 'analyze', + memberName: 'image-size', + description: 'Determines the size of an image.', + throttling: { + usages: 1, + duration: 10 + }, + args: [ + { + key: 'image', + prompt: 'What image would you like to get the size of?', + type: 'image', + default: msg => msg.author.displayAvatarURL({ format: 'png', size: 2048 }) + } + ] + }); + } + + async run(msg, { image }) { + try { + const { body } = await request.get(image); + const data = await loadImage(body); + return msg.reply(`This image is ${data.width}x${data.height}.`); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index a80b3e01..6fc3e6b0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "119.6.1", + "version": "119.7.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {