diff --git a/README.md b/README.md index 065f7599..a9e150a1 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 407 +Total: 408 ### Utility: @@ -409,6 +409,7 @@ Total: 407 ### Image Manipulation: +* **ace-attorney:** Sends a text box from Ace Attorney with the quote and character of your choice. * **achievement:** Sends a Minecraft achievement with the text of your choice. * **adorable:** Creates an adorable avatar based on the text you provide. * **apple-engraving:** Engraves the text of your choice onto an Apple product. @@ -685,6 +686,7 @@ here. - [Bulletin of the Atomic Scientists](https://thebulletin.org/) * doomsday-clock ([Doomsday Clock Data](https://thebulletin.org/doomsday-clock/current-time/)) - [Capcom](http://www.capcom.com/us/) + * ace-attorney ([Images, Original "Ace Attorney" Game](http://www.ace-attorney.com/)) * zero-dialogue ([Image, Original "Megaman Zero" Game](http://megaman.capcom.com/)) - [cheesecakejedi](https://imgur.com/user/cheesecakejedi) * axis-cult-sign-up ([Image](https://imgur.com/gallery/quQTD)) @@ -740,6 +742,8 @@ here. * hat ([Pirate Hat Image](http://dynamicpickaxe.com/pirate-hat-clipart.html)) - [ebearskittychan](https://twitter.com/ebearskittychan) * temmie (English-to-Temmie Dictionary Data) +- [Enkidulga](https://www.dafont.com/profile.php?user=736583) + * ace-attorney ([Ace Attorney Font](https://www.dafont.com/ace-attorney.font)) - [Esther Verkest](https://www.facebook.com/Esther-Verkest-49667161749/) * sos (Image) - [Evil Mojo Games](https://www.evilmojogames.com/) diff --git a/assets/fonts/Ace-Attorney.ttf b/assets/fonts/Ace-Attorney.ttf new file mode 100644 index 00000000..702049f9 Binary files /dev/null and b/assets/fonts/Ace-Attorney.ttf differ diff --git a/assets/images/ace-attorney/edgeworth.png b/assets/images/ace-attorney/edgeworth.png new file mode 100644 index 00000000..afbdd04e Binary files /dev/null and b/assets/images/ace-attorney/edgeworth.png differ diff --git a/assets/images/ace-attorney/phoenix.png b/assets/images/ace-attorney/phoenix.png new file mode 100644 index 00000000..6cd4932b Binary files /dev/null and b/assets/images/ace-attorney/phoenix.png differ diff --git a/commands/edit-image/ace-attorney.js b/commands/edit-image/ace-attorney.js new file mode 100644 index 00000000..83e59dc9 --- /dev/null +++ b/commands/edit-image/ace-attorney.js @@ -0,0 +1,87 @@ +const Command = require('../../structures/Command'); +const { createCanvas, loadImage, registerFont } = require('canvas'); +const path = require('path'); +const { list } = require('../../util/Util'); +const { wrapText } = require('../../util/Canvas'); +registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Ace-Attorney.ttf'), { family: 'Ace Attorney' }); +const characters = { + phoenix: ['phoenix', 'wright', 'naruhodo', 'ryuuichi', 'ryu', 'nick'], + edgeworth: ['miles', 'edgeworth', 'mitsurugi', 'reiji', 'edgey'] +}; + +module.exports = class AceAttorneyCommand extends Command { + constructor(client) { + super(client, { + name: 'ace-attorney', + aliases: [ + 'aa', + 'ace-attorney-dialogue', + 'aa-dialogue', + 'ace-attorney-dialog', + 'aa-dialog', + 'ace-attorney-quote', + 'aa-quote' + ], + group: 'edit-image', + memberName: 'ace-attorney', + description: 'Sends a text box from Ace Attorney with the quote and character of your choice.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'Capcom', + url: 'http://www.capcom.com/us/', + reason: 'Images, Original "Ace Attorney" Game', + reasonURL: 'http://www.ace-attorney.com/' + }, + { + name: 'Enkidulga', + url: 'https://www.dafont.com/profile.php?user=736583', + reason: 'Ace Attorney Font', + reasonURL: 'https://www.dafont.com/ace-attorney.font' + } + ], + args: [ + { + key: 'character', + prompt: `What character do you want to use? Either ${list(Object.keys(characters), 'or')}.`, + type: 'string', + oneOf: Object.values(characters).reduce((a, b) => a.concat(b)), + parse: character => { + for (const [id, arr] of Object.entries(characters)) { + if (!arr.includes(character.toLowerCase())) continue; + return id; + } + return character.toLowerCase(); + } + }, + { + key: 'quote', + prompt: 'What should the character say?', + type: 'string', + max: 250 + } + ] + }); + } + + async run(msg, { character, quote }) { + const base = await loadImage( + path.join(__dirname, '..', '..', 'assets', 'images', 'ace-attorney', `${character}.png`) + ); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + ctx.drawImage(base, 0, 0); + ctx.font = '14px Ace Attorney'; + ctx.fillStyle = 'white'; + ctx.textBaseline = 'top'; + ctx.fillText(character, 6, 178); + let text = await wrapText(ctx, quote, 242); + text = text.length > 5 ? `${text.slice(0, 5).join('\n')}...` : text.join('\n'); + ctx.fillText(text, 7, 199); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: `ace-attorney-${character}.png` }] }); + } +}; diff --git a/package.json b/package.json index 2309ce06..155a9eba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "113.21.0", + "version": "113.22.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {