diff --git a/README.md b/README.md index 8f52d1fe..9a5e5913 100644 --- a/README.md +++ b/README.md @@ -253,7 +253,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 535 +Total: 536 ### Utility: @@ -626,6 +626,7 @@ Total: 535 * **implode:** Draws an image or a user's avatar but imploded. * **invert:** Draws an image or a user's avatar but inverted. * **jeopardy-question:** Sends a Jeopardy Question with the text of your choice. +* **lego-icon:** Edits an image or avatar onto a character icon from LEGO Star Wars. * **liquid-rescale:** Draws an image or a user's avatar but with liquid rescale from ImageMagick. * **minecraft-skin:** Sends the Minecraft skin for a user. * **mirror:** Draws an image or a user's avatar but mirrored on the X/Y axis (or both). @@ -1284,6 +1285,8 @@ here. * hat (Megumin Hat Original Anime) - [Latlmes](https://www.latlmes.com/) * latlmes (API) +- [LEGO](https://www.lego.com/en-us) + * lego-icon ([Original Design](https://store.steampowered.com/app/32440/LEGO_Star_Wars__The_Complete_Saga/)) - [LMGTFY](https://lmgtfy.com/) * google (API) * lmgtfy (API) @@ -1662,6 +1665,8 @@ here. * nitro ([Image](https://www.reddit.com/r/discordapp/comments/a9fr7x/troll_your_friends_with_this/)) - [u/N1ffler](https://www.reddit.com/user/N1ffler/) * sorting-hat ([Sorting Hat Quiz Analysis Data](https://www.reddit.com/r/Pottermore/comments/44os14/pottermore_sorting_hat_quiz_analysis/)) +- [u/PowderedShmegma](https://www.reddit.com/user/PowderedShmegma/) + * lego-icon ([Image](https://www.reddit.com/r/legostarwars/comments/eheb76/lego_sw_character_icon_template/)) - [u/SupremeMemesXD](https://www.reddit.com/user/SupremeMemesXD/) * girl-worth-fighting-for ([Image](https://www.reddit.com/r/MemeTemplatesOfficial/comments/8h39vi/girl_worth_fighting_for_template/)) - [u/THANOS_COPTER](https://www.reddit.com/user/THANOS_COPTER/) diff --git a/assets/images/lego-icon.png b/assets/images/lego-icon.png new file mode 100644 index 00000000..6e43145d Binary files /dev/null and b/assets/images/lego-icon.png differ diff --git a/commands/edit-image/lego-icon.js b/commands/edit-image/lego-icon.js new file mode 100644 index 00000000..1467b3dc --- /dev/null +++ b/commands/edit-image/lego-icon.js @@ -0,0 +1,63 @@ +const Command = require('../../structures/Command'); +const { createCanvas, loadImage } = require('canvas'); +const request = require('node-superfetch'); +const path = require('path'); + +module.exports = class LegoIconCommand extends Command { + constructor(client) { + super(client, { + name: 'lego-icon', + aliases: ['icon-lego', 'lego-star-wars', 'lego-sw'], + group: 'edit-image', + memberName: 'lego-icon', + description: 'Edits an image or avatar onto a character icon from LEGO Star Wars.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'LEGO', + url: 'https://www.lego.com/en-us', + reason: 'Original Design', + reasonURL: 'https://store.steampowered.com/app/32440/LEGO_Star_Wars__The_Complete_Saga/' + }, + { + name: 'u/PowderedShmegma', + url: 'https://www.reddit.com/user/PowderedShmegma/', + reason: 'Image', + reasonURL: 'https://www.reddit.com/r/legostarwars/comments/eheb76/lego_sw_character_icon_template/' + } + ], + args: [ + { + key: 'image', + prompt: 'What image would you like to edit?', + type: 'image', + default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 }) + } + ] + }); + } + + async run(msg, { image }) { + try { + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'lego-icon.png')); + const { body } = await request.get(image); + const data = await loadImage(body); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + ctx.drawImage(base, 0, 0); + ctx.beginPath(); + ctx.arc(base.width / 2, base.height / 2, 764 / 2, 0, Math.PI * 2); + ctx.closePath(); + ctx.clip(); + const height = 764 / data.width; + ctx.drawImage(data, (base.width / 2) - (764 / 2), (base.height / 2) - (764 / 2), 764, data.height * height); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'lego-icon.png' }] }); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index 4f3bf011..bafd8a11 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "119.18.3", + "version": "119.19.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {