diff --git a/.gitignore b/.gitignore index 1aa2eca5..02eb87e2 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,3 @@ config.json command-leaderboard.json # In-Development Commands -assets/images/illegal/ -assets/json/illegal.json -commands/edit-meme/illegal.js diff --git a/README.md b/README.md index 105dfeab..5b18ed66 100644 --- a/README.md +++ b/README.md @@ -1110,7 +1110,6 @@ here. * google-feud (Autofill API) * gru-plan ([Noto Font](https://www.google.com/get/noto/)) * if-those-kids-could-read ([Noto Font](https://www.google.com/get/noto/)) - * illegal ([Noto Font](https://www.google.com/get/noto/)) * lisa-presentation ([Noto Font](https://www.google.com/get/noto/)) * map ([Maps Static API](https://developers.google.com/maps/documentation/maps-static/intro)) * mario-bros-views ([Noto Font](https://www.google.com/get/noto/)) @@ -1544,6 +1543,7 @@ here. * pokedex (Images) * whos-that-pokemon (Images) - [ShareFonts.net](https://www.wfonts.com/) + * illegal ([Impact Font](https://www.wfonts.com/font/impact)) * meme-gen-classic ([Impact Font](https://www.wfonts.com/font/impact)) - [shibe.online](https://shibe.online/) * bird (API) diff --git a/assets/images/illegal/Trump_00.png b/assets/images/illegal/Trump_00.png new file mode 100644 index 00000000..8000e72d Binary files /dev/null and b/assets/images/illegal/Trump_00.png differ diff --git a/assets/images/illegal/Trump_02.png b/assets/images/illegal/Trump_02.png new file mode 100644 index 00000000..f31ec370 Binary files /dev/null and b/assets/images/illegal/Trump_02.png differ diff --git a/assets/images/illegal/Trump_03.png b/assets/images/illegal/Trump_03.png new file mode 100644 index 00000000..ac9eabb4 Binary files /dev/null and b/assets/images/illegal/Trump_03.png differ diff --git a/assets/images/illegal/Trump_05.png b/assets/images/illegal/Trump_05.png new file mode 100644 index 00000000..877d3085 Binary files /dev/null and b/assets/images/illegal/Trump_05.png differ diff --git a/assets/images/illegal/Trump_06.png b/assets/images/illegal/Trump_06.png new file mode 100644 index 00000000..9812654b Binary files /dev/null and b/assets/images/illegal/Trump_06.png differ diff --git a/assets/images/illegal/Trump_07.png b/assets/images/illegal/Trump_07.png new file mode 100644 index 00000000..030748fa Binary files /dev/null and b/assets/images/illegal/Trump_07.png differ diff --git a/assets/images/illegal/Trump_08.png b/assets/images/illegal/Trump_08.png new file mode 100644 index 00000000..4b164782 Binary files /dev/null and b/assets/images/illegal/Trump_08.png differ diff --git a/assets/images/illegal/Trump_09.png b/assets/images/illegal/Trump_09.png new file mode 100644 index 00000000..432a7f85 Binary files /dev/null and b/assets/images/illegal/Trump_09.png differ diff --git a/assets/images/illegal/Trump_11.png b/assets/images/illegal/Trump_11.png new file mode 100644 index 00000000..10ef7d5f Binary files /dev/null and b/assets/images/illegal/Trump_11.png differ diff --git a/assets/images/illegal/Trump_12.png b/assets/images/illegal/Trump_12.png new file mode 100644 index 00000000..b4cd2d3f Binary files /dev/null and b/assets/images/illegal/Trump_12.png differ diff --git a/assets/images/illegal/Trump_14.png b/assets/images/illegal/Trump_14.png new file mode 100644 index 00000000..54e925dc Binary files /dev/null and b/assets/images/illegal/Trump_14.png differ diff --git a/assets/images/illegal/Trump_15.png b/assets/images/illegal/Trump_15.png new file mode 100644 index 00000000..2bc9bee8 Binary files /dev/null and b/assets/images/illegal/Trump_15.png differ diff --git a/assets/images/illegal/Trump_16.png b/assets/images/illegal/Trump_16.png new file mode 100644 index 00000000..e0a96b11 Binary files /dev/null and b/assets/images/illegal/Trump_16.png differ diff --git a/assets/images/illegal/Trump_17.png b/assets/images/illegal/Trump_17.png new file mode 100644 index 00000000..75efe556 Binary files /dev/null and b/assets/images/illegal/Trump_17.png differ diff --git a/assets/images/illegal/Trump_18.png b/assets/images/illegal/Trump_18.png new file mode 100644 index 00000000..8856962d Binary files /dev/null and b/assets/images/illegal/Trump_18.png differ diff --git a/assets/images/illegal/Trump_21.png b/assets/images/illegal/Trump_21.png new file mode 100644 index 00000000..574b13d7 Binary files /dev/null and b/assets/images/illegal/Trump_21.png differ diff --git a/assets/images/illegal/Trump_22.png b/assets/images/illegal/Trump_22.png new file mode 100644 index 00000000..e8728010 Binary files /dev/null and b/assets/images/illegal/Trump_22.png differ diff --git a/assets/images/illegal/Trump_24.png b/assets/images/illegal/Trump_24.png new file mode 100644 index 00000000..8cdcf83e Binary files /dev/null and b/assets/images/illegal/Trump_24.png differ diff --git a/assets/images/illegal/Trump_25.png b/assets/images/illegal/Trump_25.png new file mode 100644 index 00000000..9017e3ee Binary files /dev/null and b/assets/images/illegal/Trump_25.png differ diff --git a/assets/images/illegal/Trump_26.png b/assets/images/illegal/Trump_26.png new file mode 100644 index 00000000..a9adde25 Binary files /dev/null and b/assets/images/illegal/Trump_26.png differ diff --git a/assets/images/illegal/Trump_28.png b/assets/images/illegal/Trump_28.png new file mode 100644 index 00000000..5f344aea Binary files /dev/null and b/assets/images/illegal/Trump_28.png differ diff --git a/assets/images/illegal/Trump_29.png b/assets/images/illegal/Trump_29.png new file mode 100644 index 00000000..d742baa0 Binary files /dev/null and b/assets/images/illegal/Trump_29.png differ diff --git a/assets/images/illegal/Trump_30.png b/assets/images/illegal/Trump_30.png new file mode 100644 index 00000000..816a8c0a Binary files /dev/null and b/assets/images/illegal/Trump_30.png differ diff --git a/assets/images/illegal/Trump_32.png b/assets/images/illegal/Trump_32.png new file mode 100644 index 00000000..53974703 Binary files /dev/null and b/assets/images/illegal/Trump_32.png differ diff --git a/assets/images/illegal/Trump_33.png b/assets/images/illegal/Trump_33.png new file mode 100644 index 00000000..5b516fcd Binary files /dev/null and b/assets/images/illegal/Trump_33.png differ diff --git a/assets/images/illegal/Trump_35.png b/assets/images/illegal/Trump_35.png new file mode 100644 index 00000000..3676bd8d Binary files /dev/null and b/assets/images/illegal/Trump_35.png differ diff --git a/assets/images/illegal/Trump_37.png b/assets/images/illegal/Trump_37.png new file mode 100644 index 00000000..fe02b7ef Binary files /dev/null and b/assets/images/illegal/Trump_37.png differ diff --git a/assets/images/illegal/Trump_38.png b/assets/images/illegal/Trump_38.png new file mode 100644 index 00000000..c9485e6e Binary files /dev/null and b/assets/images/illegal/Trump_38.png differ diff --git a/assets/images/illegal/Trump_39.png b/assets/images/illegal/Trump_39.png new file mode 100644 index 00000000..fd372a30 Binary files /dev/null and b/assets/images/illegal/Trump_39.png differ diff --git a/assets/images/illegal/Trump_41.png b/assets/images/illegal/Trump_41.png new file mode 100644 index 00000000..09324a82 Binary files /dev/null and b/assets/images/illegal/Trump_41.png differ diff --git a/assets/images/illegal/Trump_42.png b/assets/images/illegal/Trump_42.png new file mode 100644 index 00000000..75bf0fa5 Binary files /dev/null and b/assets/images/illegal/Trump_42.png differ diff --git a/assets/images/illegal/Trump_43.png b/assets/images/illegal/Trump_43.png new file mode 100644 index 00000000..8a88e27d Binary files /dev/null and b/assets/images/illegal/Trump_43.png differ diff --git a/assets/images/illegal/Trump_44.png b/assets/images/illegal/Trump_44.png new file mode 100644 index 00000000..b9d49b6b Binary files /dev/null and b/assets/images/illegal/Trump_44.png differ diff --git a/assets/images/illegal/Trump_45.png b/assets/images/illegal/Trump_45.png new file mode 100644 index 00000000..2cb2dbcf Binary files /dev/null and b/assets/images/illegal/Trump_45.png differ diff --git a/assets/images/illegal/Trump_46.png b/assets/images/illegal/Trump_46.png new file mode 100644 index 00000000..c0ade555 Binary files /dev/null and b/assets/images/illegal/Trump_46.png differ diff --git a/assets/images/illegal/Trump_47.png b/assets/images/illegal/Trump_47.png new file mode 100644 index 00000000..3a41066a Binary files /dev/null and b/assets/images/illegal/Trump_47.png differ diff --git a/assets/images/illegal/Trump_48.png b/assets/images/illegal/Trump_48.png new file mode 100644 index 00000000..25adbcc2 Binary files /dev/null and b/assets/images/illegal/Trump_48.png differ diff --git a/assets/images/illegal/Trump_49.png b/assets/images/illegal/Trump_49.png new file mode 100644 index 00000000..6a7703b8 Binary files /dev/null and b/assets/images/illegal/Trump_49.png differ diff --git a/assets/images/illegal/Trump_50.png b/assets/images/illegal/Trump_50.png new file mode 100644 index 00000000..838eba95 Binary files /dev/null and b/assets/images/illegal/Trump_50.png differ diff --git a/assets/images/illegal/Trump_51.png b/assets/images/illegal/Trump_51.png new file mode 100644 index 00000000..c1b2d33f Binary files /dev/null and b/assets/images/illegal/Trump_51.png differ diff --git a/assets/images/illegal/Trump_52.png b/assets/images/illegal/Trump_52.png new file mode 100644 index 00000000..2804e128 Binary files /dev/null and b/assets/images/illegal/Trump_52.png differ diff --git a/assets/images/illegal/Trump_54.png b/assets/images/illegal/Trump_54.png new file mode 100644 index 00000000..49f93705 Binary files /dev/null and b/assets/images/illegal/Trump_54.png differ diff --git a/assets/images/illegal/Trump_55.png b/assets/images/illegal/Trump_55.png new file mode 100644 index 00000000..4a5630bc Binary files /dev/null and b/assets/images/illegal/Trump_55.png differ diff --git a/assets/images/illegal/Trump_57.png b/assets/images/illegal/Trump_57.png new file mode 100644 index 00000000..0f66fa74 Binary files /dev/null and b/assets/images/illegal/Trump_57.png differ diff --git a/assets/images/illegal/Trump_59.png b/assets/images/illegal/Trump_59.png new file mode 100644 index 00000000..2fb1f404 Binary files /dev/null and b/assets/images/illegal/Trump_59.png differ diff --git a/assets/images/illegal/Trump_60.png b/assets/images/illegal/Trump_60.png new file mode 100644 index 00000000..4704224d Binary files /dev/null and b/assets/images/illegal/Trump_60.png differ diff --git a/assets/images/illegal/Trump_62.png b/assets/images/illegal/Trump_62.png new file mode 100644 index 00000000..97991146 Binary files /dev/null and b/assets/images/illegal/Trump_62.png differ diff --git a/assets/json/illegal.json b/assets/json/illegal.json new file mode 100644 index 00000000..45f21451 --- /dev/null +++ b/assets/json/illegal.json @@ -0,0 +1,237 @@ +[ + { + "corners": [[0, 0], [0, 0], [0, 0]], + "file": "Trump_00.png", + "show": false + }, + { + "corners": [[0, 0], [0, 0], [0, 0]], + "file": "Trump_02.png", + "show": false + }, + { + "corners": [[0, 0], [0, 0], [0, 0]], + "file": "Trump_03.png", + "show": false + }, + { + "corners": [[0, 0], [0, 0], [0, 0]], + "file": "Trump_05.png", + "show": false + }, + { + "corners": [[0, 0], [0, 0], [0, 0]], + "file": "Trump_06.png", + "show": false + }, + { + "corners": [[0, 0], [0, 0], [0, 0]], + "file": "Trump_07.png", + "show": false + }, + { + "corners": [[0, 0], [0, 0], [0, 0]], + "file": "Trump_08.png", + "show": false + }, + { + "corners": [[0, 0], [0, 0], [0, 0]], + "file": "Trump_09.png", + "show": false + }, + { + "corners": [[0, 0], [0, 0], [0, 0]], + "file": "Trump_11.png", + "show": false + }, + { + "corners": [[0, 0], [0, 0], [0, 0]], + "file": "Trump_12.png", + "show": false + }, + { + "corners": [[0, 0], [0, 0], [0, 0]], + "file": "Trump_14.png", + "show": false + }, + { + "corners": [[0, 0], [0, 0], [0, 0]], + "file": "Trump_15.png", + "show": false + }, + { + "corners": [[0, 0], [0, 0], [0, 0]], + "file": "Trump_16.png", + "show": false + }, + { + "corners": [[0, 0], [0, 0], [0, 0]], + "file": "Trump_17.png", + "show": false + }, + { + "corners": [[0, 0], [0, 0], [0, 0]], + "file": "Trump_18.png", + "show": false + }, + { + "corners": [[0, 0], [0, 0], [0, 0]], + "file": "Trump_21.png", + "show": false + }, + { + "corners": [[0, 0], [0, 0], [0, 0]], + "file": "Trump_22.png", + "show": false + }, + { + "corners": [[0, 0], [0, 0], [0, 0]], + "file": "Trump_24.png", + "show": false + }, + { + "corners": [[245, 168], [206, 190], [173, 190]], + "file": "Trump_25.png", + "show": true + }, + { + "corners": [[241.0, 144], [216, 177], [166, 177.5]], + "file": "Trump_26.png", + "show": true + }, + { + "corners": [[224.5, 112.0], [253, 152], [160, 168]], + "file": "Trump_28.png", + "show": true + }, + { + "corners": [[213, 102], [268, 141], [161, 169]], + "file": "Trump_29.png", + "show": true + }, + { + "corners": [[200, 95], [272, 129], [164, 169]], + "file": "Trump_30.png", + "show": true + }, + { + "corners": [[170.5, 95.5], [238, 110], [160, 175]], + "file": "Trump_32.png", + "show": true + }, + { + "corners": [[157.0, 97.5], [219, 106], [157.0, 178.0]], + "file": "Trump_33.png", + "show": true + }, + { + "corners": [[144, 101], [199, 103], [151, 180]], + "file": "Trump_35.png", + "show": true + }, + { + "corners": [[147, 101], [202, 104], [153, 180]], + "file": "Trump_37.png", + "show": true + }, + { + "corners": [[145, 100], [202, 103], [151, 179]], + "file": "Trump_38.png", + "show": true + }, + { + "corners": [[140, 101], [202, 105], [143, 180]], + "file": "Trump_39.png", + "show": true + }, + { + "corners": [[107, 104], [182, 108], [104, 185]], + "file": "Trump_41.png", + "show": true + }, + { + "corners": [[84, 102], [163, 107], [80, 185]], + "file": "Trump_42.png", + "show": true + }, + { + "corners": [[69.5, 101], [148, 107], [62.5, 185]], + "file": "Trump_43.png", + "show": true + }, + { + "corners": [[60, 102], [137, 108], [53, 185]], + "file": "Trump_44.png", + "show": true + }, + { + "corners": [[58.0, 104], [134, 110], [49.0, 186.0]], + "file": "Trump_45.png", + "show": true + }, + { + "corners": [[62.0, 102], [137, 109], [53.0, 184]], + "file": "Trump_46.png", + "show": true + }, + { + "corners": [[83.5, 98], [138, 111], [66, 178]], + "file": "Trump_47.png", + "show": true + }, + { + "corners": [[11, 23], [39, 18], [22, 53]], + "file": "Trump_48.png", + "show": false + }, + { + "corners": [[11, 23], [39, 18], [22, 53]], + "file": "Trump_49.png", + "show": false + }, + { + "corners": [[11, 23], [39, 18], [22, 53]], + "file": "Trump_50.png", + "show": false + }, + { + "corners": [[11, 23], [39, 18], [22, 53]], + "file": "Trump_51.png", + "show": false + }, + { + "corners": [[11, 23], [39, 18], [22, 53]], + "file": "Trump_52.png", + "show": false + }, + { + "corners": [[11, 23], [39, 18], [22, 53]], + "file": "Trump_54.png", + "show": false + }, + { + "corners": [[11, 23], [39, 18], [22, 53]], + "file": "Trump_55.png", + "show": false + }, + { + "corners": [[11, 23], [39, 18], [22, 53]], + "file": "Trump_57.png", + "show": false + }, + { + "corners": [[11, 23], [39, 18], [22, 53]], + "file": "Trump_59.png", + "show": false + }, + { + "corners": [[11, 23], [39, 18], [22, 53]], + "file": "Trump_60.png", + "show": false + }, + { + "corners": [[11, 23], [39, 18], [22, 53]], + "file": "Trump_62.png", + "show": false + } +] diff --git a/commands/edit-avatar/fire.js b/commands/edit-avatar/fire.js index 132a3611..0da49621 100644 --- a/commands/edit-avatar/fire.js +++ b/commands/edit-avatar/fire.js @@ -17,7 +17,7 @@ module.exports = class FireCommand extends Command { description: 'Burns a user\'s avatar.', throttling: { usages: 1, - duration: 10 + duration: 30 }, clientPermissions: ['ATTACH_FILES'], credit: [ diff --git a/commands/edit-avatar/triggered.js b/commands/edit-avatar/triggered.js index 5c5a30c8..aea3fa00 100644 --- a/commands/edit-avatar/triggered.js +++ b/commands/edit-avatar/triggered.js @@ -18,7 +18,7 @@ module.exports = class TriggeredCommand extends Command { description: 'Draws a user\'s avatar over the "Triggered" meme.', throttling: { usages: 1, - duration: 10 + duration: 30 }, clientPermissions: ['ATTACH_FILES'], credit: [ diff --git a/commands/edit-meme/illegal.js b/commands/edit-meme/illegal.js index 8115fcdd..b43e3bb6 100644 --- a/commands/edit-meme/illegal.js +++ b/commands/edit-meme/illegal.js @@ -1,10 +1,10 @@ const Command = require('../../structures/Command'); const { createCanvas, loadImage, registerFont } = require('canvas'); +const GIFEncoder = require('gifencoder'); const path = require('path'); -const { wrapText } = 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' }); +const { streamToArray } = require('../../util/Util'); +const frames = require('../../assets/json/illegal'); +registerFont(path.join(__dirname, '..', '..', 'assets', 'fonts', 'Impact.ttf'), { family: 'Impact' }); module.exports = class IllegalCommand extends Command { constructor(client) { @@ -16,7 +16,7 @@ module.exports = class IllegalCommand extends Command { description: 'Makes President Trump make your text illegal.', throttling: { usages: 1, - duration: 10 + duration: 30 }, clientPermissions: ['ATTACH_FILES'], credit: [ @@ -26,10 +26,10 @@ module.exports = class IllegalCommand extends Command { reason: 'Himself, Image' }, { - name: 'Google', - url: 'https://www.google.com/', - reason: 'Noto Font', - reasonURL: 'https://www.google.com/get/noto/' + name: 'ShareFonts.net', + url: 'https://www.wfonts.com/', + reason: 'Impact Font', + reasonURL: 'https://www.wfonts.com/font/impact' } ], args: [ @@ -53,21 +53,33 @@ module.exports = class IllegalCommand extends Command { } async run(msg, { text, verb }) { - const base = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'illegal.png')); - const canvas = createCanvas(base.width, base.height); + const encoder = new GIFEncoder(262, 264); + const stream = encoder.createReadStream(); + encoder.start(); + encoder.setRepeat(0); + encoder.setDelay(100); + encoder.setQuality(200); + const canvas = createCanvas(262, 264); const ctx = canvas.getContext('2d'); - ctx.drawImage(base, 0, 0); - ctx.rotate(7 * (Math.PI / 180)); - const illegalText = `${text} ${verb} NOW ILLEGAL.`; - let fontSize = 45; - ctx.font = `${fontSize}px Noto`; - while (ctx.measureText(illegalText).width > 550) { - fontSize--; - ctx.font = `${fontSize}px Noto`; + for (const frame of frames) { + const img = await loadImage(path.join(__dirname, '..', '..', 'assets', 'images', 'illegal', frame.file)); + ctx.drawImage(img, 0, 0); + if (!frame.show) { + encoder.addFrame(ctx); + ctx.clearRect(0, 0, canvas.width, canvas.height); + continue; + } + ctx.textBaseline = 'top'; + ctx.font = '20px Impact'; + const widthMid = frame.corners[2][0] - frame.corners[0][0]; + const heightMid = frame.corners[2][1] - frame.corners[0][1]; + const maxLen = frame.corners[0][0] - frame.corners[2][0]; + ctx.fillText(`${text}\n${verb} NOW\nILLEGAL`, widthMid, heightMid, maxLen); + encoder.addFrame(Ctx); + ctx.clearRect(0, 0, canvas.width, canvas.height); } - const lines = await wrapText(ctx, illegalText, 200); - ctx.fillText(lines.join('\n'), 750, 290); - ctx.rotate(-7 * (Math.PI / 180)); - return msg.say({ files: [{ attachment: canvas.toBuffer(), name: 'illegal.png' }] }); + encoder.finish(); + const buffer = await streamToArray(stream); + return msg.say({ files: [{ attachment: Buffer.concat(buffer), name: 'illegal.gif' }] }); } }; diff --git a/package.json b/package.json index 652f25fc..28c9bc1d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "119.17.4", + "version": "119.17.5", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {