diff --git a/README.md b/README.md index e88f80e0..f159f273 100644 --- a/README.md +++ b/README.md @@ -224,7 +224,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 432 +Total: 433 ### Utility: @@ -519,6 +519,7 @@ Total: 432 * **axis-cult-sign-up:** Sends an Axis Cult Sign-Up sheet for you. Join today! * **brazzers:** Draws an image with the Brazzers logo in the corner. (NSFW) * **certificate:** Sends a certificate of excellence with the name and reason of your choice. +* **chinese-restaurant:** Sends a Chinese restaurant sign with the text of your choice. * **circle:** Draws an image or a user's avatar as a circle. * **color:** Sends an image of the color you choose. * **contrast:** Draws an image or a user's avatar but with contrast. @@ -791,6 +792,8 @@ here. * itunes ([iTunes Search API](https://affiliate.itunes.apple.com/resources/documentation/itunes-store-web-service-search-api/)) - [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/)) - [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)) @@ -891,6 +894,7 @@ here. - [FML](https://www.fmylife.com/) * fml (FML Data) - [Fontsgeek](http://fontsgeek.com/) + * chinese-restaurant ([Futura Condensed Font](http://fontsgeek.com/fonts/Futura-Condensed-Bold)) * skyrim-skill ([Futura Condensed Font](http://fontsgeek.com/fonts/Futura-Condensed-Regular)) - [Foreign exchange rates API](https://exchangeratesapi.io/) * currency (API) diff --git a/assets/images/chinese-restaurant.png b/assets/images/chinese-restaurant.png new file mode 100644 index 00000000..782fca83 Binary files /dev/null and b/assets/images/chinese-restaurant.png differ diff --git a/commands/edit-image/chinese-restaurant.js b/commands/edit-image/chinese-restaurant.js new file mode 100644 index 00000000..33c24a82 --- /dev/null +++ b/commands/edit-image/chinese-restaurant.js @@ -0,0 +1,74 @@ +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', 'Futura Condensed.ttf'), { + family: 'Futura', + weight: 'bold' +}); + +module.exports = class ChineseRestaurantCommand extends Command { + constructor(client) { + super(client, { + name: 'chinese-restaurant', + aliases: ['chinese-restaurant-sign', 'chinese-food-sign', 'chinese-sign'], + group: 'edit-image', + memberName: 'chinese-restaurant', + description: 'Sends a Chinese restaurant 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/chinese/' + }, + { + name: 'Fontsgeek', + url: 'http://fontsgeek.com/', + reason: 'Futura Condensed Font', + reasonURL: 'http://fontsgeek.com/fonts/Futura-Condensed-Bold' + } + ], + 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', 'chinese-restaurant.png')); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + ctx.drawImage(base, 0, 0); + ctx.fillStyle = 'black'; + ctx.textAlign = 'center'; + ctx.textBaseline = 'top'; + ctx.font = 'normal bold 28px Futura'; + const lines = await wrapText(ctx, text.toUpperCase(), 340); + if (lines.length === 1) { + ctx.fillText(lines[0], base.width / 2, 294); + } else if (lines.length === 2) { + ctx.fillText(lines[0], base.width / 2, 294); + ctx.fillText(lines[1], base.width / 2, 323); + } else if (lines.length === 3) { + ctx.fillText(lines[0], base.width / 2, 269); + ctx.fillText(lines[1], base.width / 2, 294); + ctx.fillText(lines[2], base.width / 2, 323); + } else { + ctx.fillText(lines[0], base.width / 2, 269); + ctx.fillText(lines[1], base.width / 2, 294); + ctx.fillText(lines[2], base.width / 2, 323); + ctx.fillText(lines[4], base.width / 2, 350); + } + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'chinese-restaurant.png' }] }); + } +}; diff --git a/package.json b/package.json index 6f404581..0cc5aa88 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "114.20.0", + "version": "114.21.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {