From 3c86875e200f096cfe03a026ae6b18ca6ea2aecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DedShot=E2=84=A2=239195?= Date: Fri, 24 Apr 2020 03:49:20 -0400 Subject: [PATCH] Deleted mdn.ts because it's in the wrong place --- mdn.ts | 67 ---------------------------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 mdn.ts diff --git a/mdn.ts b/mdn.ts deleted file mode 100644 index 6052d7b..0000000 --- a/mdn.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { Message } from 'eris'; -import axios from 'axios'; -import { Client, Command, RichEmbed } from '../class'; - -export default class Mdn extends Command { - constructor(client: Client) { - super(client); - this.name = 'mdn'; - this.description = 'Get information from mdn about JavaScript.'; - this.usage = 'mdn [.property/.method]'; - this.permissions = 0; - this.guildOnly = false; - this.enabled = true; - this.aliases = ['js']; - } - - public async run(message: Message, args: string[]) { - try { - if (!args[0]) return this.error(message.channel, 'You need to specify an argument.'); - args[0] = args[0].replace('.', '.prototype.'); - args[0] = args[0].replace('#', '.prototype.'); - - return axios.get(`https://mdn.pleb.xyz/search?q=${args[0]}`) - .then((res) => { - if (res.status !== 200 || res.statusText !== 'OK') return this.error(message.channel, 'Please try again later, something unexpected happened.'); - const { data } = res; - if (!data.Title || !data.Summary || !data.URL) return this.error(message.channel, 'Could not find information. Try something else.'); - - // Do not touch to the next block of code. Don't even look at it. your brain could stop working - data.Summary = data.Summary.replace(//g, ''); - data.Summary = data.Summary.replace(/<\/strong><\/code>/g, ''); - data.Summary = data.Summary.replace(//g, '`'); - data.Summary = data.Summary.replace(/<\/code>/g, '`'); - data.Summary = data.Summary.replace(//g, '**'); - data.Summary = data.Summary.replace(/<\/strong>/g, '**'); - const url = data.Summary.match(//); - if (url !== null) { - url[0] = url[0].replace('/, `[${name[0]}](https://developer.mozilla.org${url[0]})`); - } - - const embed = new RichEmbed(); - embed.setAuthor('Mozilla Developer Network', 'https://i.imgur.com/DFGXabG.png', 'https://developer.mozilla.org/en-US'); - embed.setTitle(data.Title); - embed.setDescription(data.Summary); - embed.setURL(`developer.mozilla.org${data.URL}`); - embed.setColor(0x066fad); - embed.setFooter(this.client.user.username, this.client.user.avatarURL); - embed.setTimestamp(); - return message.channel.createMessage({ embed }); - }) - .catch((err) => { - this.client.util.handleError(err, message, this); - this.error(message.channel, 'Please try again later, something unexpected happened.'); - }); - } catch (err) { - return this.client.util.handleError(err, message, this); - } - } -}