diff --git a/README.md b/README.md index 47b5cff3..0baf00ca 100644 --- a/README.md +++ b/README.md @@ -224,7 +224,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 433 +Total: 434 ### Utility: @@ -534,6 +534,7 @@ Total: 433 * **glass-shatter:** Draws an image or a user's avatar with a glass shatter in front of it. * **glitch:** Draws an image or a user's avatar but glitched. * **greyscale:** Draws an image or a user's avatar in greyscale. +* **highway-sign:** Sends a highway sign sign with the text of your choice. * **hollywood-star:** Sends a Hollywood Walk of Fame star with the name of your choice. * **ifunny:** Draws an image with the iFunny logo. * **invert:** Draws an image or a user's avatar but inverted. @@ -791,10 +792,13 @@ here. * alert ([San Francisco Font](https://developer.apple.com/fonts/)) * apple-engraving (API) * 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)) - [astrology.TV](https://astrology.tv/) * horoscope ([Horoscope Data](https://astrology.tv/horoscope/daily/)) - [ATOM.SMASHER.ORG](http://atom.smasher.org/) * chinese-restaurant ([Image](http://atom.smasher.org/chinese/)) + * highway-sign ([Image](http://atom.smasher.org/construction/)) - [Attype Studio](https://www.dafont.com/fadli-ramadhan-iskandar.d7339) * friendship ([Pinky Cupid Font](https://www.dafont.com/pinky-cupid.font)) * ship ([Pinky Cupid Font](https://www.dafont.com/pinky-cupid.font)) diff --git a/assets/fonts/EHSMB.ttf b/assets/fonts/EHSMB.ttf new file mode 100644 index 00000000..16c1059d Binary files /dev/null and b/assets/fonts/EHSMB.ttf differ diff --git a/assets/images/highway-sign.png b/assets/images/highway-sign.png new file mode 100644 index 00000000..32e13f13 Binary files /dev/null and b/assets/images/highway-sign.png differ diff --git a/commands/edit-image/highway-sign.js b/commands/edit-image/highway-sign.js new file mode 100644 index 00000000..d7616e41 --- /dev/null +++ b/commands/edit-image/highway-sign.js @@ -0,0 +1,71 @@ +const Command = require('../../structures/Command'); +const { createCanvas, loadImage, registerFont } = require('canvas'); +const path = require('path'); +const { wrapText } = require('../../util/Canvas'); +registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'EHSMB.ttf'), { family: 'Electronic Highway Sign' }); + +module.exports = class HighwaySignCommand extends Command { + constructor(client) { + super(client, { + name: 'highway-sign', + aliases: ['road-sign', 'road-work-sign', 'electronic-highway-sign'], + group: 'edit-image', + memberName: 'highway-sign', + description: 'Sends a highway sign sign with the text of your choice.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'ATOM.SMASHER.ORG', + url: 'http://atom.smasher.org/', + reason: 'Image', + reasonURL: 'http://atom.smasher.org/construction/' + }, + { + name: 'Ash Pikachu Font', + url: 'https://www.dafont.com/ashpikachu099.d2541', + reason: 'Electronic Highway Sign Font', + reasonURL: 'https://www.dafont.com/electronic-highway-sign.font' + } + ], + args: [ + { + key: 'text', + prompt: 'What should the text of the sign be?', + type: 'string' + } + ] + }); + } + + async run(msg, { text }) { + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'highway-sign.png')); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + ctx.drawImage(base, 0, 0); + ctx.fillStyle = '#efe390'; + ctx.textAlign = 'center'; + ctx.textBaseline = 'top'; + ctx.font = '18px Electronic Highway Sign'; + const lines = await wrapText(ctx, text.toUpperCase(), 178); + if (lines.length === 1) { + ctx.fillText(lines[0], 89, 109); + } else if (lines.length === 2) { + ctx.fillText(lines[0], 89, 109); + ctx.fillText(lines[1], 89, 128); + } else if (lines.length === 3) { + ctx.fillText(lines[0], 89, 90); + ctx.fillText(lines[1], 89, 109); + ctx.fillText(lines[2], 89, 128); + } else { + ctx.fillText(lines[0], 89, 90); + ctx.fillText(lines[1], 89, 109); + ctx.fillText(lines[2], 89, 128); + ctx.fillText(lines[4], 89, 147); + } + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'highway-sign.png' }] }); + } +}; diff --git a/package.json b/package.json index 05235020..7507266f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "114.22.0", + "version": "114.23.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {