diff --git a/README.md b/README.md index 2861686f..7b34e5f9 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ served over 10,000 servers with a uniquely devoted fanbase. * **fruit**: Responds with a random fruit. * **guess-looks**: Guesses what a user looks like. * **joke**: Responds with a random joke. +* **karen**: Responds with a random image of Karen. * **kiss-marry-kill**: Determines who to kiss, who to marry, and who to kill. * **magic-conch**: Asks your question to the Magic Conch. * **name**: Responds with a random name, with the gender of your choice. @@ -218,6 +219,7 @@ served over 10,000 servers with a uniquely devoted fanbase. * **glitch**: Draws an image or a user's avatar but glitched. * **greyscale**: Draws an image or a user's avatar in greyscale. * **ifunny**: Draws an image with the iFunny logo. +* **illegal**: Makes President Trump make your text illegal. * **invert**: Draws an image or a user's avatar but inverted. * **meme**: Sends a meme with the text and background of your choice. * **osu-signature**: Creates a card based on an osu! user's stats. diff --git a/assets/images/illegal.png b/assets/images/illegal.png new file mode 100644 index 00000000..e407d1cc Binary files /dev/null and b/assets/images/illegal.png differ diff --git a/commands/analyze/face.js b/commands/analyze/face.js index 9f4f034f..5b50c77d 100644 --- a/commands/analyze/face.js +++ b/commands/analyze/face.js @@ -15,8 +15,7 @@ module.exports = class FaceAnalyzeCommand extends Command { { key: 'face', prompt: 'What face do you want to scan?', - type: 'image', - default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 }) + type: 'image' } ] }); diff --git a/commands/image-edit/illegal.js b/commands/image-edit/illegal.js new file mode 100644 index 00000000..b18dccc9 --- /dev/null +++ b/commands/image-edit/illegal.js @@ -0,0 +1,60 @@ +const { Command } = require('discord.js-commando'); +const { createCanvas, loadImage, registerFont } = require('canvas'); +const { stripIndents } = require('common-tags'); +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 IllegalCommand extends Command { + constructor(client) { + super(client, { + name: 'illegal', + aliases: ['is-now-illegal', 'trump', 'first-order-of-business'], + group: 'image-edit', + memberName: 'illegal', + description: 'Makes President Trump make your text illegal.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + args: [ + { + key: 'text', + prompt: 'What should the text of the bill be?', + type: 'string', + parse: text => text.toUpperCase() + }, + { + key: 'isOrAre', + label: 'is or are', + prompt: 'Should the text use is or are?', + type: 'string', + default: 'is', + validate: isOrAre => { + if (['is', 'are'].includes(isOrAre.toLowerCase())) return true; + return 'Invalid is or are, please enter either is or are.'; + }, + parse: isOrAre => isOrAre.toUpperCase() + } + ] + }); + } + + async run(msg, { text, isOrAre }) { + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'illegal.png')); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + ctx.drawImage(base, 0, 0); + ctx.rotate(7 * (Math.PI / 180)); + ctx.font = '37px Noto'; + ctx.fillText(stripIndents` + ${shortenText(ctx, text, 215)} + ${isOrAre} NOW + ILLEGAL. + `, 690, 350); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'illegal.png' }] }); + } +}; diff --git a/commands/random/karen.js b/commands/random/karen.js new file mode 100644 index 00000000..8f8322cd --- /dev/null +++ b/commands/random/karen.js @@ -0,0 +1,24 @@ +const { Command } = require('discord.js-commando'); +const { randomFromImgurAlbum } = require('../../util/Util'); + +module.exports = class KarenCommand extends Command { + constructor(client) { + super(client, { + name: 'karen', + aliases: ['ayaya'], + group: 'random', + memberName: 'karen', + description: 'Responds with a random image of Karen.', + clientPermissions: ['ATTACH_FILES'] + }); + } + + async run(msg) { + try { + const karen = await randomFromImgurAlbum('3oLAP'); + return msg.say({ files: [karen] }); + } catch (err) { + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/commands/search/http-cat.js b/commands/search/http-cat.js index 3326a082..44dfdf4d 100644 --- a/commands/search/http-cat.js +++ b/commands/search/http-cat.js @@ -21,8 +21,8 @@ module.exports = class HTTPCatCommand extends Command { async run(msg, { code }) { try { - const { body, text } = await snekfetch.get(`https://http.cat/${code}.jpg`); - if (text.startsWith('')) return msg.say('Could not find any results.'); + const { body, headers } = await snekfetch.get(`https://http.cat/${code}.jpg`); + if (headers['content-type'] === 'text/html') return msg.say('Could not find any results.'); return msg.say({ files: [{ attachment: body, name: `${code}.jpg` }] }); } catch (err) { return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); diff --git a/commands/util/ping.js b/commands/util/ping.js index c7d14ead..3e769b4c 100644 --- a/commands/util/ping.js +++ b/commands/util/ping.js @@ -15,8 +15,9 @@ module.exports = class PingCommand extends Command { async run(msg) { const message = await msg.say('Pinging...'); + const ping = Math.round(message.createdTimestamp - msg.createdTimestamp); return message.edit(stripIndents` - 🏓 Pong! \`${Math.round(message.createdTimestamp - msg.createdTimestamp)}ms\` + 🏓 P${'o'.repeat(Math.ceil(ping / 100))}ng! \`${ping}ms\` Heartbeat: \`${Math.round(this.client.ping)}ms\` `); } diff --git a/package.json b/package.json index 1b7275e0..7a811844 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "69.2.0", + "version": "69.3.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {