diff --git a/README.md b/README.md index be0f2713..6083822e 100644 --- a/README.md +++ b/README.md @@ -227,7 +227,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 489 +Total: 491 ### Utility: @@ -594,6 +594,7 @@ Total: 489 * **silhouette:** Draws a silhouette of an image or a user's avatar. * **simp:** Draws a "simp" stamp over an image or a user's avatar. * **snapcode:** Responds with the Snapcode of a Snapchat user. +* **speed-limit:** Sends a Speed Limit sign with the limit of your choice. * **spongebob-time-card:** Sends a Spongebob Time Card with the text of your choice. * **square:** Draws an image or a user's avatar as a square. * **squish:** Draws an image or a user's avatar but squished across the X or Y axis. @@ -601,6 +602,7 @@ Total: 489 * **tint:** Draws an image or a user's avatar but tinted a specific color. * **tweet:** Sends a Twitter tweet with the user and text of your choice. * **undertale:** Sends a text box from Undertale with the quote and character of your choice. +* **you-died:** Sends a "You Died" screen over an image or a user's avatar. * **yu-gi-oh-gen:** Draws an image or a user's avatar on a Yu-Gi-Oh! Trading Card with the text of your choice. * **yu-gi-oh-token:** Draws a user's avatar over a blank Yu-Gi-Oh! Token card. * **zero-dialogue:** Sends a text box from Megaman Zero with the quote of your choice. @@ -855,6 +857,7 @@ here. * itunes ([iTunes Search API](https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/)) - [Ash Pikachu Font](https://www.dafont.com/ashpikachu099.d2541) * highway-sign ([Electronic Highway Sign Font](https://www.dafont.com/electronic-highway-sign.font)) + * speed-limit ([Highway Gothic Font](https://www.dafont.com/highway-gothic.font)) - [astrology.TV](https://astrology.tv/) * horoscope ([Horoscope Data](https://astrology.tv/horoscope/daily/)) - [ATOM.SMASHER.ORG](http://atom.smasher.org/) @@ -994,6 +997,8 @@ here. * hat ([Birthday Hat Image](https://www.freeiconspng.com/img/43917)) - [Frinkiac](https://frinkiac.com/) * frinkiac (API) +- [FromSoftware](https://www.fromsoftware.jp/ww/) + * you-died (Image, Original "Dark Souls" Game) - [Gallery Yopriceville](https://gallery.yopriceville.com/) * hat ([Pilgrim Hat Image](https://gallery.yopriceville.com/Free-Clipart-Pictures/Thanksgiving-PNG/Transparent_Brown_Pilgrim_Hat_PNG_Clipart)) - [gautamkrishnar](https://github.com/gautamkrishnar/) @@ -1297,9 +1302,11 @@ here. * pogchamp (Concept) * porn (Original Subreddit List) * simp (Concept) + * speed-limit (Concept) * thicc (Concept) * undertale (Concept) * worse-than-hitler (Concept) + * you-died (Concept) - [PAC-MAN Party](http://pacman.com/en/pac-man-games/pac-man-party) * balloon-pop (Concept) - [PaladinsGuru](https://paladins.guru/) @@ -1376,6 +1383,8 @@ here. * right-stuf (API) - [Riot Games](https://www.riotgames.com/en) * league-of-legends ([API](https://developer.riotgames.com/)) +- [RoadTrafficSigns](https://www.roadtrafficsigns.com/) + * speed-limit ([Image](https://www.roadtrafficsigns.com/speed-limit-sign/speed-limit-70-sign/sku-x-r2-1-70.aspx)) - [RoboHash](https://robohash.org/) * robohash (API) - [Robotatertot](https://robotatertot.tumblr.com/) diff --git a/assets/fonts/HWYGWDE.ttf b/assets/fonts/HWYGWDE.ttf new file mode 100644 index 00000000..7cb90e33 Binary files /dev/null and b/assets/fonts/HWYGWDE.ttf differ diff --git a/assets/images/speed-limit.png b/assets/images/speed-limit.png new file mode 100644 index 00000000..6a5d6cc7 Binary files /dev/null and b/assets/images/speed-limit.png differ diff --git a/assets/images/you-died.png b/assets/images/you-died.png new file mode 100644 index 00000000..fcaab086 Binary files /dev/null and b/assets/images/you-died.png differ diff --git a/commands/edit-image/speed-limit.js b/commands/edit-image/speed-limit.js new file mode 100644 index 00000000..20a08597 --- /dev/null +++ b/commands/edit-image/speed-limit.js @@ -0,0 +1,60 @@ +const Command = require('../../structures/Command'); +const { createCanvas, loadImage, registerFont } = require('canvas'); +const path = require('path'); +registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'HWYGWDE.ttf'), { family: 'Highway Gothic' }); + +module.exports = class SpeedLimitCommand extends Command { + constructor(client) { + super(client, { + name: 'speed-limit', + aliases: ['speed', 'speed-limit-sign'], + group: 'edit-image', + memberName: 'speed-limit', + description: 'Sends a Speed Limit sign with the limit of your choice.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'RoadTrafficSigns', + url: 'https://www.roadtrafficsigns.com/', + reason: 'Image', + reasonURL: 'https://www.roadtrafficsigns.com/speed-limit-sign/speed-limit-70-sign/sku-x-r2-1-70.aspx' + }, + { + name: 'Ash Pikachu Font', + url: 'https://www.dafont.com/ashpikachu099.d2541', + reason: 'Highway Gothic Font', + reasonURL: 'https://www.dafont.com/highway-gothic.font' + }, + { + name: 'Overtime2005', + url: 'https://github.com/Overtime2005', + reason: 'Concept' + } + ], + args: [ + { + key: 'limit', + prompt: 'What limit should be on the sign?', + type: 'string', + max: 5 + } + ] + }); + } + + async run(msg, { limit }) { + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'speed-limit.png')); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + ctx.drawImage(base, 0, 0); + ctx.textBaseline = 'top'; + ctx.font = '360px Highway Gothic'; + ctx.fillStyle = 'black'; + ctx.fillText(limit.toUpperCase(), 87, 356, 475); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'speed-limit.png' }] }); + } +}; diff --git a/commands/edit-image/you-died.js b/commands/edit-image/you-died.js new file mode 100644 index 00000000..c06ed4c6 --- /dev/null +++ b/commands/edit-image/you-died.js @@ -0,0 +1,61 @@ +const Command = require('../../structures/Command'); +const { createCanvas, loadImage } = require('canvas'); +const request = require('node-superfetch'); +const path = require('path'); +const { centerImage, greyscale, drawImageWithTint } = require('../../util/Canvas'); + +module.exports = class YouDiedCommand extends Command { + constructor(client) { + super(client, { + name: 'you-died', + aliases: ['died', 'dead'], + group: 'edit-image', + memberName: 'you-died', + description: 'Sends a "You Died" screen over an image or a user\'s avatar.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'FromSoftware', + url: 'https://www.fromsoftware.jp/ww/', + reason: 'Image, Original "Dark Souls" Game' + }, + { + name: 'Overtime2005', + url: 'https://github.com/Overtime2005', + reason: 'Concept' + } + ], + 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', 'you-died.png')); + const { body } = await request.get(image); + const data = await loadImage(body); + const canvas = createCanvas(data.width, data.height); + const ctx = canvas.getContext('2d'); + drawImageWithTint(ctx, data, 'black', 0, 0, data.width, data.height); + greyscale(ctx, 0, 0, data.width, data.height); + const { x, y, width, height } = centerImage(base, data); + ctx.drawImage(base, x, y, width, height); + const attachment = canvas.toBuffer(); + if (Buffer.byteLength(attachment) > 8e+6) return msg.reply('Resulting image was above 8 MB.'); + return msg.say({ files: [{ attachment, name: 'you-died.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 c66fb54b..a313d78a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "116.30.0", + "version": "116.31.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {