diff --git a/README.md b/README.md index 46e00c38..25c2cbd0 100644 --- a/README.md +++ b/README.md @@ -580,6 +580,7 @@ Total: 529 * **approved:** Draws an "approved" stamp over an image or a user's avatar. * **axis-cult-sign-up:** Sends an Axis Cult Sign-Up sheet for you. Join today! * **blur:** Draws an image or a user's avatar but blurred. +* **bob-ross:** Draws an image or a user's avatar over Bob Ross' canvas. * **brazzers:** Draws an image with the Brazzers logo in the corner. (NSFW) * **caution:** Creates a caution sign with the text of your choice. * **certificate:** Sends a certificate of excellence with the name and reason of your choice. @@ -636,11 +637,13 @@ Total: 529 * **spongebob-time-card:** Sends a Spongebob Time Card with the text of your choice. * **square:** Draws an image or a user's avatar as a square. * **squish:** Draws an image or a user's avatar but squished across the X or Y axis. +* **steam-card:** Draws an image or a user's avatar on a Steam Trading Card. * **subtitle:** Adds subtitles to an image. * **swirl:** Draws an image or a user's avatar but swirled. * **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. * **undertale:** Sends a text box from Undertale with the quote and character of your choice. +* **wanted:** Draws an image or a user's avatar over a wanted poster. * **wild-pokemon:** Draws an image or a user's avatar over a wild Pokémon appearance. * **you-died:** Sends a "You Died" screen over an image or a user's avatar. * **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. @@ -650,22 +653,18 @@ Total: 529 ### Avatar Manipulation: * **avatar-fusion:** Draws a a user's avatar over a user's avatar. -* **bob-ross:** Draws a user's avatar over Bob Ross' canvas. * **chocolate-milk:** Draws a user's avatar holding chocolate milk. * **fire:** Burns a user's avatar. * **hat:** Draws a hat over a user's avatar. * **he-lives-in-you:** Draws a user's avatar over Simba from The Lion King's reflection. * **hearts:** Draws hearts around a user's avatar. * **i-have-the-power:** Draws a user's avatar over He-Man's face. -* **look-what-karen-have:** Draws a user's avatar over Karen's piece of paper. * **rip:** Draws a user's avatar over a gravestone. * **sip:** Draws a user's avatar sipping tea. * **status-button:** Creates a Discord status button from c99.nl. -* **steam-card:** Draws a user's avatar on a Steam Trading Card. * **steam-now-playing-classic:** Draws a user's avatar over a Steam "now playing" notification (old skin). * **steam-now-playing:** Draws a user's avatar over a Steam "now playing" notification. * **triggered:** Draws a user's avatar over the "Triggered" meme. -* **wanted:** Draws a user's avatar over a wanted poster. ### Meme Generators: @@ -700,6 +699,7 @@ Total: 529 * **like:** Sends an "Everyone Liked That" meme with the image of your choice. * **lisa-presentation:** Sends a "Lisa Presentation" meme with the presentation of your choice. * **look-at-this-photograph:** Draws an image or a user's avatar over Nickelback's photograph. +* **look-what-karen-have:** Draws an image or a user's avatar over Karen's piece of paper. * **mario-bros-views:** Sends a "Mario Bros. Views" meme with the text of your choice. * **meme-gen-classic:** Sends a meme with the text and background of your choice. * **meme-gen-modern:** Sends a meme with the text and image of your choice. diff --git a/commands/edit-avatar/bob-ross.js b/commands/edit-image/bob-ross.js similarity index 69% rename from commands/edit-avatar/bob-ross.js rename to commands/edit-image/bob-ross.js index 28868c29..e156b650 100644 --- a/commands/edit-avatar/bob-ross.js +++ b/commands/edit-image/bob-ross.js @@ -2,15 +2,16 @@ const Command = require('../../structures/Command'); const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); +const { centerImagePart } = require('../../util/Canvas'); module.exports = class BobRossCommand extends Command { constructor(client) { super(client, { name: 'bob-ross', aliases: ['ross'], - group: 'edit-avatar', + group: 'edit-image', memberName: 'bob-ross', - description: 'Draws a user\'s avatar over Bob Ross\' canvas.', + description: 'Draws an image or a user\'s avatar over Bob Ross\' canvas.', throttling: { usages: 1, duration: 10 @@ -31,26 +32,26 @@ module.exports = class BobRossCommand extends Command { ], args: [ { - key: 'user', - prompt: 'Which user would you like to edit the avatar of?', - type: 'user', - default: msg => msg.author + key: 'image', + prompt: 'What image would you like to edit?', + type: 'image', + default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 }) } ] }); } - async run(msg, { user }) { - const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 }); + async run(msg, { image }) { try { const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'bob-ross.png')); - const { body } = await request.get(avatarURL); - const avatar = await loadImage(body); + 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(avatar, 15, 20, 440, 440); + const { x, y, width, height } = centerImagePart(data, 440, 440, 15, 20); + ctx.drawImage(data, x, y, width, height); ctx.drawImage(base, 0, 0); return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'bob-ross.png' }] }); } catch (err) { diff --git a/commands/edit-avatar/steam-card.js b/commands/edit-image/steam-card.js similarity index 74% rename from commands/edit-avatar/steam-card.js rename to commands/edit-image/steam-card.js index 43375b36..f8fd962c 100644 --- a/commands/edit-avatar/steam-card.js +++ b/commands/edit-image/steam-card.js @@ -11,9 +11,9 @@ module.exports = class SteamCardCommand extends Command { super(client, { name: 'steam-card', aliases: ['valve-card'], - group: 'edit-avatar', + group: 'edit-image', memberName: 'steam-card', - description: 'Draws a user\'s avatar on a Steam Trading Card.', + description: 'Draws an image or a user\'s avatar on a Steam Trading Card.', throttling: { usages: 1, duration: 10 @@ -41,32 +41,38 @@ module.exports = class SteamCardCommand extends Command { ], args: [ { - key: 'user', - prompt: 'Which user would you like to edit the avatar of?', - type: 'user', - default: msg => msg.author + key: 'name', + prompt: 'What do you want the card to be named?', + type: 'string', + max: 50 + }, + { + key: 'image', + prompt: 'What image would you like to edit?', + type: 'image', + default: msg => msg.author.displayAvatarURL({ format: 'png', size: 256 }) } ] }); } - async run(msg, { user }) { - const avatarURL = user.displayAvatarURL({ format: 'png', size: 256 }); + async run(msg, { name, image }) { try { const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'steam-card.png')); - const { body } = await request.get(avatarURL); - const avatar = await loadImage(body); + 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 = '#feb2c1'; ctx.fillRect(0, 0, base.width, base.height); - ctx.drawImage(avatar, 12, 19, 205, 205); + const height = 205 / data.width; + ctx.drawImage(data, 12, 19, 205, height * data.height); ctx.drawImage(base, 0, 0); ctx.font = '14px Noto'; ctx.fillStyle = 'black'; - ctx.fillText(user.username, 16, 25); + ctx.fillText(name, 16, 25); ctx.fillStyle = 'white'; - ctx.fillText(user.username, 15, 24); + ctx.fillText(name, 15, 24); return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'steam-card.png' }] }); } catch (err) { return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); diff --git a/commands/edit-avatar/wanted.js b/commands/edit-image/wanted.js similarity index 64% rename from commands/edit-avatar/wanted.js rename to commands/edit-image/wanted.js index 2f66ed4e..17cffecf 100644 --- a/commands/edit-avatar/wanted.js +++ b/commands/edit-image/wanted.js @@ -2,16 +2,16 @@ const Command = require('../../structures/Command'); const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); -const { sepia } = require('../../util/Canvas'); +const { sepia, centerImagePart } = require('../../util/Canvas'); module.exports = class WantedCommand extends Command { constructor(client) { super(client, { name: 'wanted', aliases: ['wanted-poster'], - group: 'edit-avatar', + group: 'edit-image', memberName: 'wanted', - description: 'Draws a user\'s avatar over a wanted poster.', + description: 'Draws an image or a user\'s avatar over a wanted poster.', throttling: { usages: 1, duration: 10 @@ -27,26 +27,26 @@ module.exports = class WantedCommand extends Command { ], args: [ { - key: 'user', - prompt: 'Which user would you like to edit the avatar of?', - type: 'user', - default: msg => msg.author + key: 'image', + prompt: 'What image would you like to edit?', + type: 'image', + default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 }) } ] }); } - async run(msg, { user }) { - const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 }); + async run(msg, { image }) { try { const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'wanted.png')); - const { body } = await request.get(avatarURL); - const avatar = await loadImage(body); + const { body } = await request.get(image); + const data = await loadImage(body); const canvas = createCanvas(base.width, base.height); const ctx = canvas.getContext('2d'); ctx.drawImage(base, 0, 0); - ctx.drawImage(avatar, 150, 360, 430, 430); - sepia(ctx, 150, 360, 430, 430); + const { x, y, width, height } = centerImagePart(data, 430, 430, 150, 360); + ctx.drawImage(data, x, y, width, height); + sepia(ctx, x, y, width, height); return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'wanted.png' }] }); } catch (err) { return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); diff --git a/commands/edit-avatar/look-what-karen-have.js b/commands/edit-meme/look-what-karen-have.js similarity index 72% rename from commands/edit-avatar/look-what-karen-have.js rename to commands/edit-meme/look-what-karen-have.js index aabed7cd..021ce673 100644 --- a/commands/edit-avatar/look-what-karen-have.js +++ b/commands/edit-meme/look-what-karen-have.js @@ -2,15 +2,16 @@ const Command = require('../../structures/Command'); const { createCanvas, loadImage } = require('canvas'); const request = require('node-superfetch'); const path = require('path'); +const { centerImagePart } = require('../../util/Canvas'); module.exports = class LookWhatKarenHaveCommand extends Command { constructor(client) { super(client, { name: 'look-what-karen-have', aliases: ['look-at-what-karen-has', 'look-what-karen-has'], - group: 'edit-avatar', + group: 'edit-meme', memberName: 'look-what-karen-have', - description: 'Draws a user\'s avatar over Karen\'s piece of paper.', + description: 'Draws an image or a user\'s avatar over Karen\'s piece of paper.', throttling: { usages: 1, duration: 10 @@ -31,27 +32,27 @@ module.exports = class LookWhatKarenHaveCommand extends Command { ], args: [ { - key: 'user', - prompt: 'Which user would you like to edit the avatar of?', - type: 'user', - default: msg => msg.author + key: 'image', + prompt: 'What image would you like to edit?', + type: 'image', + default: msg => msg.author.displayAvatarURL({ format: 'png', size: 512 }) } ] }); } - async run(msg, { user }) { - const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 }); + async run(msg, { image }) { try { const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'look-what-karen-have.png')); - const { body } = await request.get(avatarURL); - const avatar = await loadImage(body); + 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.rotate(-6.5 * (Math.PI / 180)); - ctx.drawImage(avatar, 514, 50, 512, 512); + const { x, y, width, height } = centerImagePart(data, 512, 512, 514, 50); + ctx.drawImage(data, x, y, width, height); ctx.rotate(6.5 * (Math.PI / 180)); ctx.drawImage(base, 0, 0); return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'look-what-karen-have.png' }] }); diff --git a/package.json b/package.json index 6b6564f4..dc473cce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "119.10.0", + "version": "119.10.1", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {