diff --git a/README.md b/README.md index f92dd3ce..7448df20 100644 --- a/README.md +++ b/README.md @@ -227,7 +227,7 @@ in the appropriate channel's topic to use it. ## Commands -Total: 476 +Total: 477 ### Utility: @@ -594,6 +594,7 @@ Total: 476 * **subtitle:** Adds subtitles to an image. * **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. +* **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. * **zero-dialogue:** Sends a text box from Megaman Zero with the quote of your choice. ### Avatar Manipulation: @@ -874,6 +875,8 @@ here. * doomsday-clock ([Doomsday Clock Data](https://thebulletin.org/doomsday-clock/current-time/)) - [bunnies.io](https://www.bunnies.io/) * bunny (API) +- [bushin](https://www.cardmaker.net/profile/220983-bushin/) + * yu-gi-oh-gen ([Fonts](https://www.cardmaker.net/forums/topic/308603-fonts-for-yu-gi-oh-card-making-with-multilingual-support/)) - [calzoneman](https://github.com/calzoneman) * dec-talk ([API](https://github.com/calzoneman/aeiou)) - [Capcom](http://www.capcom.com/us/) @@ -906,6 +909,8 @@ here. * cow-say (API) - [Creative Certificates](https://www.creativecertificates.com/) * certificate ([Image](https://www.creativecertificates.com/award-certificate-templates/)) +- [cylgom](https://www.deviantart.com/cylgom) + * yu-gi-oh-gen ([Card Base Template](https://www.deviantart.com/cylgom/art/Yu-GI-Oh-ultra-faithful-monster-card-template-728814822)) - [Danbooru](https://danbooru.donmai.us/) * danbooru (API) - [Dance Dance Revolution](https://www.ddrgame.com/) @@ -1059,6 +1064,8 @@ here. * rip ([Coffin Stone Font](https://www.fontspace.com/coffin-stone-font-f40998)) - [iCrawl](https://github.com/iCrawl) * butt ([Code, Concept](https://github.com/iCrawl/Tohru/blob/master/src/commands/fun/butts.js)) +- [icycatelf](https://www.deviantart.com/icycatelf) + * yu-gi-oh-gen ([Level Star Image](https://www.deviantart.com/icycatelf/art/Level-Star-Template-PSD-607344453)) - [iFunny](https://ifunny.co/) * ifunny (Logo) - [Illumination](http://www.illumination.com/) @@ -1136,6 +1143,7 @@ here. * look-what-karen-have ([Image](https://knowyourmeme.com/photos/1047091-kin-iro-mosaic-kinmoza)) - [Konami](https://www.konami.com/en/) * yu-gi-oh ([Original "Yu-Gi-Oh!" Game](https://www.yugioh-card.com/en/)) + * yu-gi-oh-gen ([Images, Original "Yu-Gi-Oh!" Game](https://www.yugioh-card.com/en/)) * yu-gi-oh-token ([Image, Original "Yu-Gi-Oh!" Game](https://www.yugioh-card.com/en/)) - [KONOSUBA -God's blessing on this wonderful world!](http://konosuba.com/) * axis-cult (Original Anime) diff --git a/assets/fonts/Matrix Book.ttf b/assets/fonts/Matrix Book.ttf new file mode 100644 index 00000000..c0bd7686 Binary files /dev/null and b/assets/fonts/Matrix Book.ttf differ diff --git a/assets/fonts/Matrix Small Caps.ttf b/assets/fonts/Matrix Small Caps.ttf new file mode 100644 index 00000000..73adbeb9 Binary files /dev/null and b/assets/fonts/Matrix Small Caps.ttf differ diff --git a/assets/fonts/Stone Serif Semibold.ttf b/assets/fonts/Stone Serif Semibold.ttf new file mode 100644 index 00000000..7875cbae Binary files /dev/null and b/assets/fonts/Stone Serif Semibold.ttf differ diff --git a/assets/fonts/Stone Serif Small Caps.ttf b/assets/fonts/Stone Serif Small Caps.ttf new file mode 100644 index 00000000..27cebf3d Binary files /dev/null and b/assets/fonts/Stone Serif Small Caps.ttf differ diff --git a/assets/images/yu-gi-oh-gen/atr.png b/assets/images/yu-gi-oh-gen/atr.png new file mode 100644 index 00000000..829e5ef8 Binary files /dev/null and b/assets/images/yu-gi-oh-gen/atr.png differ diff --git a/assets/images/yu-gi-oh-gen/base.png b/assets/images/yu-gi-oh-gen/base.png new file mode 100644 index 00000000..d281b915 Binary files /dev/null and b/assets/images/yu-gi-oh-gen/base.png differ diff --git a/assets/images/yu-gi-oh-gen/level.png b/assets/images/yu-gi-oh-gen/level.png new file mode 100644 index 00000000..59966f9f Binary files /dev/null and b/assets/images/yu-gi-oh-gen/level.png differ diff --git a/commands/edit-image/yu-gi-oh-gen.js b/commands/edit-image/yu-gi-oh-gen.js new file mode 100644 index 00000000..7e44da31 --- /dev/null +++ b/commands/edit-image/yu-gi-oh-gen.js @@ -0,0 +1,132 @@ +const Command = require('../../structures/Command'); +const { createCanvas, loadImage, registerFont } = require('canvas'); +const request = require('node-superfetch'); +const path = require('path'); +const { wrapText } = require('../../util/Canvas'); +registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Matrix Book.ttf'), { family: 'Matrix Book' }); +registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Matrix Small Caps.ttf'), { family: 'Matrix' }); +registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Stone Serif Semibold.ttf'), { + family: 'Stone Serif', + weight: 'semibold' +}); +registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Stone Serif Small Caps.ttf'), { + family: 'Stone Serif', + weight: 'smallcaps' +}); + +module.exports = class YuGiOhGenCommand extends Command { + constructor(client) { + super(client, { + name: 'yu-gi-oh-gen', + aliases: ['ygo-gen', 'yu-gi-oh-generator', 'ygo-generator'], + group: 'edit-image', + memberName: 'yu-gi-oh-gen', + description: 'Draws an image or a user\'s avatar on a Yu-Gi-Oh! Trading Card with the text of your choice.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + credit: [ + { + name: 'Konami', + url: 'https://www.konami.com/en/', + reason: 'Images, Original "Yu-Gi-Oh!" Game', + reasonURL: 'https://www.yugioh-card.com/en/' + }, + { + name: 'cylgom', + url: 'https://www.deviantart.com/cylgom', + reason: 'Card Base Template', + reasonURL: 'https://www.deviantart.com/cylgom/art/Yu-GI-Oh-ultra-faithful-monster-card-template-728814822' + }, + { + name: 'icycatelf', + url: 'https://www.deviantart.com/icycatelf', + reason: 'Level Star Image', + reasonURL: 'https://www.deviantart.com/icycatelf/art/Level-Star-Template-PSD-607344453' + }, + { + name: 'bushin', + url: 'https://www.cardmaker.net/profile/220983-bushin/', + reason: 'Fonts', + // eslint-disable-next-line max-len + reasonURL: 'https://www.cardmaker.net/forums/topic/308603-fonts-for-yu-gi-oh-card-making-with-multilingual-support/' + } + ], + args: [ + { + key: 'name', + prompt: 'What do you want the card to be named?', + type: 'string', + max: 50 + }, + { + key: 'effect', + prompt: 'What should the card\'s effect be?', + type: 'string' + }, + { + key: 'type', + prompt: 'What type should the card be?', + type: 'string', + max: 25 + }, + { + key: 'level', + prompt: 'What level should the card be?', + type: 'integer', + min: 1, + max: 12 + }, + { + key: 'image', + prompt: 'What image would you like to edit?', + type: 'image', + default: msg => msg.author.displayAvatarURL({ format: 'png', size: 256 }) + } + ] + }); + } + + async run(msg, { name, effect, type, level, image }) { + const id = Math.floor(Math.random() * 100000000); + const setID = Math.floor(Math.random() * 1000); + try { + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'yu-gi-oh-gen', 'base.png')); + const atr = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'yu-gi-oh-gen', 'atr.png')); + const levelI = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'yu-gi-oh-gen', 'level.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.fillStyle = 'white'; + ctx.fillRect(0, 0, base.width, base.height); + ctx.drawImage(data, 109, 241, 590, 590); + ctx.drawImage(base, 0, 0); + ctx.drawImage(atr, 669, 61, 77, 77); + for (let i = 0; i < level; i++) { + const x = 676 - (676 * i) - (5 * i); + ctx.drawImage(levelI, x, 160); + } + ctx.font = '14px Noto'; + ctx.fillStyle = 'black'; + ctx.textBaseline = 'top'; + ctx.font = '87px Matrix'; + ctx.fillText(name, 74, 79, 585); + ctx.font = '27px Matrix Book'; + const wrappedEffect = await wrapText(ctx, effect, 660); + ctx.fillText(wrappedEffect.join('\n'), 76, 929); + ctx.font = 'normal smallcaps 31px Stone Serif'; + ctx.fillText(`[ ${type} / Effect ]`, 77, 896); + ctx.font = 'normal semibold 22px Stone Serif'; + ctx.fillText(id.toString().padStart(8, '0'), 37, 1134); + ctx.fillText(`XIAO-${setID.toString().padStart(3, '0')}`, 572, 856); + ctx.font = 'normal semibold 21px Stone Serif'; + ctx.fillText('⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺⸺', 81, 1060); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'yu-gi-oh-gen.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 ce0acb10..c7f0a5eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "116.19.0", + "version": "116.20.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {