From b578e365ce5d084fbcfb964b8e8aa94d54b2f8fc Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Sun, 12 Jan 2020 18:51:51 -0500 Subject: [PATCH] Newspaper Command --- README.md | 3 +- commands/image-edit/newspaper.js | 48 ++++++++++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 commands/image-edit/newspaper.js diff --git a/README.md b/README.md index cf1cc026..38f31ffe 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Xiao is a Discord bot coded in JavaScript with * [Rando Cardrissian](https://github.com/dragonfire535/rando-cardrissian) is a Cards Against Humanity bot, whose features were originally built into Xiao. -## Commands (350) +## Commands (351) ### Utility: * **eval:** Executes JavaScript code. @@ -309,6 +309,7 @@ Xiao is a Discord bot coded in JavaScript with * **invert:** Draws an image or a user's avatar but inverted. * **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. +* **newspaper:** Creates a fake newspaper with the headline and body of your choice. * **pixelize:** Draws an image or a user's avatar pixelized. * **pokemon-fusion:** Fuses two Generation I Pokémon together. * **rainbow:** Draws a rainbow over an image or a user's avatar. diff --git a/commands/image-edit/newspaper.js b/commands/image-edit/newspaper.js new file mode 100644 index 00000000..41c8f758 --- /dev/null +++ b/commands/image-edit/newspaper.js @@ -0,0 +1,48 @@ +const Command = require('../../structures/Command'); +const request = require('node-superfetch'); +const moment = require('moment'); + +module.exports = class NewspaperCommand extends Command { + constructor(client) { + super(client, { + name: 'newspaper', + group: 'analyze', + memberName: 'newspaper', + description: 'Creates a fake newspaper with the headline and body of your choice.', + credit: [ + { + name: 'The Newspaper Clipping Generator', + url: 'https://www.fodey.com/generators/newspaper/snippet.asp' + } + ], + args: [ + { + key: 'headline', + prompt: 'What do you want the headline to be?', + type: 'string', + max: 20 + }, + { + key: 'body', + prompt: 'What should the body of the article be?', + type: 'string' + } + ] + }); + } + + async run(msg, { headline, body }) { + try { + const { text } = await request + .post('https://www.fodey.com/generators/newspaper/snippet.asp') + .attach('name', 'The Daily Whatever') + .attach('date', moment().format('dddd, MMMM D, YYYY')) + .attach('headline', headline) + .attach('text', body); + const newspaperURL = text.match(/