diff --git a/README.md b/README.md index 8b68dc78..bc9fab1f 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Xiao is a Discord bot coded in JavaScript with Xiao is no longer available for invite. You can self-host the bot, or use her on the [home server](https://discord.gg/sbMe32W). -## Commands (326) +## Commands (327) ### Utility: * **eval:** Executes JavaScript code. @@ -262,6 +262,7 @@ the [home server](https://discord.gg/sbMe32W). * **meme-gen:** Sends a meme with the text and background of your choice. * **minecraft-skin:** Sends the Minecraft skin for a user. * **needs-more-jpeg:** Draws an image or a user's avatar as a low quality JPEG. +* **new-password:** Sends a "Weak Password/Strong Password" meme with the passwords of your choice. * **nike-ad:** Sends a "Believe in Something" Nike Ad meme with the text of your choice. * **osu-signature:** Creates a card based on an osu! user's stats. * **pixelize:** Draws an image or a user's avatar pixelized. diff --git a/assets/images/new-password.png b/assets/images/new-password.png new file mode 100644 index 00000000..bd68a49d Binary files /dev/null and b/assets/images/new-password.png differ diff --git a/commands/image-edit/new-password.js b/commands/image-edit/new-password.js new file mode 100644 index 00000000..bb41b5e2 --- /dev/null +++ b/commands/image-edit/new-password.js @@ -0,0 +1,47 @@ +const Command = require('../../structures/Command'); +const { createCanvas, loadImage, registerFont } = require('canvas'); +const path = require('path'); +const { shortenText } = require('../../util/Canvas'); +registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Regular.ttf'), { family: 'Noto' }); +registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-CJK.otf'), { family: 'Noto' }); +registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Noto-Emoji.ttf'), { family: 'Noto' }); + +module.exports = class NewPasswordCommand extends Command { + constructor(client) { + super(client, { + name: 'new-password', + aliases: ['strong-password', 'new-pswd', 'strong-pswd'], + group: 'image-edit', + memberName: 'new-password', + description: 'Sends a "Weak Password/Strong Password" meme with the passwords of your choice.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + args: [ + { + key: 'weak', + prompt: 'What should the text of the weak password be?', + type: 'string' + }, + { + key: 'strong', + prompt: 'What should the text of the strong password be?', + type: 'string' + } + ] + }); + } + + async run(msg, { weak, strong }) { + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'new-password.png')); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + ctx.drawImage(base, 0, 0); + ctx.font = '25px Noto'; + ctx.fillText(shortenText(ctx, weak, 400), 48, 113); + ctx.fillText(shortenText(ctx, strong, 400), 48, 351); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'new-password.png' }] }); + } +}; diff --git a/package.json b/package.json index 0220348c..2b6c1c74 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "93.0.0", + "version": "93.1.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {