From 9a217cc1398121dff0e063470876198fd9e5cd3a Mon Sep 17 00:00:00 2001 From: loicbersier Date: Sun, 6 Sep 2020 22:53:57 +0200 Subject: [PATCH] Fetch video from petittube.com Signed-off-by: loicbersier --- commands/fun/petittube.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 commands/fun/petittube.js diff --git a/commands/fun/petittube.js b/commands/fun/petittube.js new file mode 100644 index 00000000..e713172f --- /dev/null +++ b/commands/fun/petittube.js @@ -0,0 +1,30 @@ +const { Command } = require('discord-akairo'); +const fetch = require('node-fetch'); +const cheerio = require('cheerio'); + +class PetitTubeCommand extends Command { + constructor() { + super('petittube', { + aliases: ['petittube', 'pt'], + category: 'fun', + clientPermissions: ['SEND_MESSAGES', 'ATTACH_FILES'], + description: { + content: 'Fetch a video from https://petittube.com/', + usage: '', + examples: [''] + } + }); + } + + async exec(message) { + const response = await fetch('https://petittube.com/'); + const body = await response.text(); + + const $ = cheerio.load(body); + + const url = $('iframe')[0].attribs.src; + + this.client.commandHandler.runCommand(message, this.client.commandHandler.findCommand('download'), { link: new URL(url), proxy: 1, spoiler: true, caption: 'Video might be NSFW as always, be careful!'}); + } +} +module.exports = PetitTubeCommand; \ No newline at end of file