From 6cf4f9c8e3f91a90c76a1a5601e121f97247b091 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Wed, 22 Apr 2020 14:45:49 -0400 Subject: [PATCH 1/9] perms fix (@dedshot) --- src/class/Command.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/class/Command.ts b/src/class/Command.ts index 7fc00f5..7a2e5c5 100644 --- a/src/class/Command.ts +++ b/src/class/Command.ts @@ -68,8 +68,10 @@ export default class Command { case 4: return member.roles.some((r) => ['701454780828221450', '701454855952138300', '662163685439045632'].includes(r)); case 5: - return member.roles.some((r) => ['701454855952138300', '662163685439045632'].includes(r)); + return member.roles.some((r) => ['455972169449734144', '701454780828221450', '701454855952138300', '662163685439045632'].includes(r)); case 6: + return member.roles.some((r) => ['701454855952138300', '662163685439045632'].includes(r)); + case 7: return member.roles.includes('662163685439045632'); default: return false; -- 2.20.1 From 6be5c2d48c496ab66d3780041e7384f71f094acc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DedShot=E2=84=A2=239195?= Date: Thu, 23 Apr 2020 19:44:45 -0400 Subject: [PATCH 2/9] Added mdn docs command --- mdn.ts | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 mdn.ts diff --git a/mdn.ts b/mdn.ts new file mode 100644 index 0000000..6052d7b --- /dev/null +++ b/mdn.ts @@ -0,0 +1,67 @@ +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); + } + } +} -- 2.20.1 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 3/9] 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); - } - } -} -- 2.20.1 From 399a32a48b0a3f9a29ccfebb97e7b41acab5b6a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DedShot=E2=84=A2=239195?= Date: Fri, 24 Apr 2020 03:50:48 -0400 Subject: [PATCH 4/9] Changed location of mdn.ts to the correct one --- mdn.ts | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 mdn.ts diff --git a/mdn.ts b/mdn.ts new file mode 100644 index 0000000..c4418e6 --- /dev/null +++ b/mdn.ts @@ -0,0 +1,66 @@ +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); + }); + } catch (err) { + return this.client.util.handleError(err, message, this); + } + } +} -- 2.20.1 From 28783684f7084f10497283ace9dfd59a8c9c0b49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DedShot=E2=84=A2=239195?= Date: Fri, 24 Apr 2020 03:51:48 -0400 Subject: [PATCH 5/9] Delete mdn.ts cuz its still in the wrong place --- mdn.ts | 66 ---------------------------------------------------------- 1 file changed, 66 deletions(-) delete mode 100644 mdn.ts diff --git a/mdn.ts b/mdn.ts deleted file mode 100644 index c4418e6..0000000 --- a/mdn.ts +++ /dev/null @@ -1,66 +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); - }); - } catch (err) { - return this.client.util.handleError(err, message, this); - } - } -} -- 2.20.1 From 933e58051dbb1b9ff558c8b9715c61b18ab7b1e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DedShot=E2=84=A2=239195?= Date: Fri, 24 Apr 2020 03:52:54 -0400 Subject: [PATCH 6/9] correct location 2 --- src/commands/mdn.ts | 66 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/commands/mdn.ts diff --git a/src/commands/mdn.ts b/src/commands/mdn.ts new file mode 100644 index 0000000..c4418e6 --- /dev/null +++ b/src/commands/mdn.ts @@ -0,0 +1,66 @@ +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); + }); + } catch (err) { + return this.client.util.handleError(err, message, this); + } + } +} -- 2.20.1 From b9f789e62836401d27b751964caabe8ea1a20aef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DedShot=E2=84=A2=239195?= Date: Tue, 5 May 2020 06:55:36 -0400 Subject: [PATCH 7/9] mdn command returns help when no args specified --- src/commands/mdn.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/commands/mdn.ts b/src/commands/mdn.ts index c4418e6..54650dd 100644 --- a/src/commands/mdn.ts +++ b/src/commands/mdn.ts @@ -16,13 +16,12 @@ export default class Mdn extends Command { public async run(message: Message, args: string[]) { try { - if (!args[0]) return this.error(message.channel, 'You need to specify an argument.'); + if (!args[0]) return this.client.commands.get('help').run(message, [this.name]); 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.'); @@ -54,9 +53,11 @@ export default class Mdn extends Command { embed.setColor(0x066fad); embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setTimestamp(); + return message.channel.createMessage({ embed }); }) .catch((err) => { + this.error(message.channel, 'Please try again later, something unexpected happened.'); this.client.util.handleError(err, message, this); }); } catch (err) { -- 2.20.1 From cd86c3f7ee5f0f0ddd935ffbbdcd8f48fe7d7b75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DedShot=E2=84=A2=239195?= Date: Sat, 9 May 2020 22:33:32 -0400 Subject: [PATCH 8/9] used await instead of .then().catch() (KhaaZ) --- src/commands/mdn.ts | 78 ++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/src/commands/mdn.ts b/src/commands/mdn.ts index 54650dd..31c55ab 100644 --- a/src/commands/mdn.ts +++ b/src/commands/mdn.ts @@ -2,7 +2,7 @@ import { Message } from 'eris'; import axios from 'axios'; import { Client, Command, RichEmbed } from '../class'; -export default class Mdn extends Command { +export default class MDN extends Command { constructor(client: Client) { super(client); this.name = 'mdn'; @@ -20,46 +20,46 @@ export default class Mdn extends Command { 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) => { - const { data } = res; - if (!data.Title || !data.Summary || !data.URL) return this.error(message.channel, 'Could not find information. Try something else.'); + let res; + try { + res = await axios.get(`https://mdn.pleb.xyz/search?q=${args[0]}`); + } catch (err) { + this.error(message.channel, 'Please try again later, something unexpected happened.'); + return this.client.util.handleError(err, message, this); + } + const { data } = res; + if (!data || !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]})`); - } + // 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.error(message.channel, 'Please try again later, something unexpected happened.'); - this.client.util.handleError(err, message, this); - }); + 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) { return this.client.util.handleError(err, message, this); } -- 2.20.1 From d71a15905495fd34eafb89adb400ce3ae4a68e37 Mon Sep 17 00:00:00 2001 From: Bsian Date: Wed, 20 May 2020 06:49:07 -0400 Subject: [PATCH 9/9] Apply suggestion to src/commands/mdn.ts --- src/commands/mdn.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/commands/mdn.ts b/src/commands/mdn.ts index 31c55ab..95e2a54 100644 --- a/src/commands/mdn.ts +++ b/src/commands/mdn.ts @@ -33,10 +33,8 @@ export default class MDN extends Command { // 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, '**'); + data.Summary = data.Summary.replace(/|<\/code>/g, '`'); + data.Summary = data.Summary.replace(`/|<\/strong>/g, '**');` const url = data.Summary.match(//); if (url !== null) { url[0] = url[0].replace('