diff --git a/README.md b/README.md index f2c04eaf..9e6d9eb7 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Xiao is a Discord bot coded in JavaScript with The bot is no longer available for invite. You can self-host the bot, or use her on the [home server](https://discord.gg/sbMe32W). -## Commands (294) +## Commands (295) ### Utility: * **eval**: Executes JavaScript code. @@ -271,6 +271,7 @@ on the [home server](https://discord.gg/sbMe32W). * **steam-card**: Draws a user's avatar on a Steam Trading Card. * **steam-now-playing**: Draws a user's avatar and the game of your choice over a Steam "now playing" notification. * **the-ultimate-tattoo**: Draws a user's avatar as "The Ultimate Tattoo". +* **this-is-worthless**: Draws a user's useless avatar. * **thug-life**: Draws "Thug Life" over a user's avatar. * **triggered**: Draws a user's avatar over the "Triggered" meme. * **wanted**: Draws a user's avatar over a wanted poster. diff --git a/assets/images/this-is-worthless.png b/assets/images/this-is-worthless.png new file mode 100644 index 00000000..a74863ac Binary files /dev/null and b/assets/images/this-is-worthless.png differ diff --git a/commands/avatar-edit/this-is-worthless.js b/commands/avatar-edit/this-is-worthless.js new file mode 100644 index 00000000..cfcb0f7b --- /dev/null +++ b/commands/avatar-edit/this-is-worthless.js @@ -0,0 +1,49 @@ +const Command = require('../../structures/Command'); +const { createCanvas, loadImage } = require('canvas'); +const request = require('node-superfetch'); +const path = require('path'); + +module.exports = class ThisIsWorthlessCommand extends Command { + constructor(client) { + super(client, { + name: 'this-is-worthless', + aliases: ['worthless'], + group: 'avatar-edit', + memberName: 'this-is-worthless', + description: 'Draws a user\'s useless avatar.', + throttling: { + usages: 1, + duration: 10 + }, + clientPermissions: ['ATTACH_FILES'], + args: [ + { + key: 'user', + prompt: 'Which user would you like to edit the avatar of?', + type: 'user', + default: msg => msg.author + } + ] + }); + } + + async run(msg, { user }) { + const avatarURL = user.displayAvatarURL({ format: 'png', size: 512 }); + try { + const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'this-is-worthless.png')); + const { body } = await request.get(avatarURL); + const avatar = await loadImage(body); + const canvas = createCanvas(base.width, base.height); + const ctx = canvas.getContext('2d'); + ctx.drawImage(base, 0, 0); + ctx.rotate(6 * (Math.PI / 180)); + ctx.drawImage(avatar, 521, 241, 400, 400); + ctx.rotate(163 * (Math.PI / 180)); + ctx.drawImage(avatar, 957, 1434, 70, 70); + ctx.rotate(-168 * (Math.PI / 180)); + return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'this-is-worthless.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 a95e81ca..05ece9d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "87.3.0", + "version": "87.4.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { @@ -47,7 +47,7 @@ "zlib-sync": "^0.1.4" }, "devDependencies": { - "eslint": "^5.3.0", + "eslint": "^5.4.0", "eslint-config-amber": "^1.1.0", "eslint-plugin-json": "^1.2.1" },