From ef31fc3abc62b7b5551bb4328af266a1a4595222 Mon Sep 17 00:00:00 2001 From: Matthew Ray Date: Sun, 17 May 2020 21:59:21 -0400 Subject: [PATCH 1/8] Fixes #7 --- src/class/RichEmbed.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/class/RichEmbed.ts b/src/class/RichEmbed.ts index 307f9c5..fba5d52 100644 --- a/src/class/RichEmbed.ts +++ b/src/class/RichEmbed.ts @@ -87,7 +87,7 @@ export default class RichEmbed implements EmbedData { */ setURL(url: string) { if (typeof url !== 'string') throw new TypeError('RichEmbed URLs must be a string.'); - if (!url.startsWith('http://') || !url.startsWith('https://')) url = `https://${url}`; + if (!url.startsWith('http://') && !url.startsWith('https://')) url = `https://${url}`; this.url = encodeURI(url); return this; } From ecaa8611357748e4f18ed1b8bc1df541e12df2c5 Mon Sep 17 00:00:00 2001 From: Bsian Date: Wed, 20 May 2020 12:17:47 +0100 Subject: [PATCH 2/8] Send debugs to see reason for ws disconnect --- src/main.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.ts b/src/main.ts index 5213da2..15a9f77 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,6 +3,7 @@ */ import { parse } from 'yaml'; import { promises as fs } from 'fs'; +import { TextChannel } from 'eris'; import { Client } from './class'; async function main(): Promise { @@ -16,6 +17,7 @@ async function main(): Promise { await client.loadEvents(); await client.loadCommands(); client.connect(); + client.once('ready', () => client.on('debug', (message) => (client.getChannel('592170164322041856') as TextChannel).createMessage(message))); } main(); From ef22cd76ddfa5b81ddebf33c55c3eac8306eae5a Mon Sep 17 00:00:00 2001 From: Bsian Date: Wed, 20 May 2020 14:52:11 +0100 Subject: [PATCH 3/8] Stop debugging messages --- src/main.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 15a9f77..80839a1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -17,7 +17,10 @@ async function main(): Promise { await client.loadEvents(); await client.loadCommands(); client.connect(); - client.once('ready', () => client.on('debug', (message) => (client.getChannel('592170164322041856') as TextChannel).createMessage(message))); + client.once('ready', () => client.on('debug', (message) => { + if (message.includes('/messages')) return; + (client.getChannel('592170164322041856') as TextChannel).createMessage(message); + })); } main(); From 7d6e4bb6a6e07c8a2d7c159838c2d593f2cb7df6 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Fri, 12 Jun 2020 01:28:55 -0400 Subject: [PATCH 4/8] rm logging --- src/main.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main.ts b/src/main.ts index d142218..a8ff92c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -19,10 +19,6 @@ async function main(): Promise { await client.loadEvents(eventFiles); await client.loadCommands(commandFiles); client.connect(); - client.once('ready', () => client.on('debug', (message) => { - if (message.includes('/messages')) return; - (client.getChannel('592170164322041856') as TextChannel).createMessage(message); - })); } main(); From 4f23f38351c75f6ed85b2948a9b15080cb589fee Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 28 Jul 2020 19:22:41 +0100 Subject: [PATCH 5/8] Use pluris instead --- package.json | 3 ++- src/class/Client.ts | 3 +++ yarn.lock | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index c2a1b87..88044d3 100644 --- a/package.json +++ b/package.json @@ -27,13 +27,14 @@ }, "dependencies": { "axios": "^0.19.2", - "eris": "bsian03/eris#bsian", + "eris": "^0.13.3", "eris-pagination": "bsian03/eris-pagination", "express": "^4.17.1", "helmet": "^3.22.0", "moment": "^2.25.3", "mongoose": "^5.9.13", "nodemailer": "^6.4.8", + "pluris": "^0.2.5", "signale": "^1.4.0", "uuid": "^8.0.0", "yaml": "^1.9.2" diff --git a/src/class/Client.ts b/src/class/Client.ts index f6bafa9..417b747 100644 --- a/src/class/Client.ts +++ b/src/class/Client.ts @@ -1,10 +1,13 @@ import eris from 'eris'; +import pluris from 'pluris'; import mongoose from 'mongoose'; import { promises as fs } from 'fs'; import { Collection, Command, LocalStorage, Util, ServerManagement, Event } from '.'; import { File, FileInterface, Member, MemberInterface, Moderation, ModerationInterface, Note, NoteInterface, PagerNumber, PagerNumberInterface, Rank, RankInterface, Redirect, RedirectInterface, Stat, StatInterface } from '../models'; import { Config } from '../../types'; // eslint-disable-line +pluris(eris); + export default class Client extends eris.Client { public config: Config; diff --git a/yarn.lock b/yarn.lock index a86aef4..24ddf67 100644 --- a/yarn.lock +++ b/yarn.lock @@ -603,9 +603,10 @@ eris-reactions@^0.1.2: resolved "https://registry.yarnpkg.com/eris-reactions/-/eris-reactions-0.1.2.tgz#2d4edbf5f80dc964f0bb42fd301d3d8a141a5aa1" integrity sha512-p497xAdNsw3RRfAoklYemWRk1HT22rBmRaiemG6TVZ1yPTuQf41r4GteyKOJZ3hkphD3Rte7/1GiZwPzUNOHcw== -eris@bsian03/eris#bsian: - version "0.13.1" - resolved "https://codeload.github.com/bsian03/eris/tar.gz/b363a59225db374eca1547adba201310cb3489f4" +eris@^0.13.3: + version "0.13.3" + resolved "https://registry.yarnpkg.com/eris/-/eris-0.13.3.tgz#22abb71f9ce0d453200b537cad457dc39c7b302b" + integrity sha512-WBtLyknOWZpYZL9yPhez0oKUWvYpunSg43hGxawwjwSf3gFXmbEPYrT8KlmZXtpJnX16eQ7mzIq+MgSh3LarEg== dependencies: ws "^7.2.1" optionalDependencies: @@ -1668,6 +1669,15 @@ pkg-dir@^2.0.0: dependencies: find-up "^2.1.0" +pluris@^0.2.5: + version "0.2.5" + resolved "https://registry.yarnpkg.com/pluris/-/pluris-0.2.5.tgz#e98d8e0e7a49432b8bfe168b46e919e55405259e" + integrity sha512-K7UsbUn7uKflcnLRwN9g4sSlFsGYtM+sYhrO+nFrNTay/Gn6wTnhZlMbiIg1dXIy6+gnpVQZqVGghmBJb9t1Pg== + dependencies: + eris "^0.13.3" + optionalDependencies: + eris-reactions "^0.1.2" + prelude-ls@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" From 0a35b339f4107dc536bab5cb4104d4320845f655 Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 28 Jul 2020 19:57:07 +0100 Subject: [PATCH 6/8] Stop trying to lint built files --- .eslintrc.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index 19880fc..da54f5a 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -42,5 +42,6 @@ "import/extensions": "off", "no-param-reassign": "off", "no-underscore-dangle": "off" - } + }, + "ignorePatterns": "**/*.js" } From 55e602d619b05d6272b15f401633a3f0080e0a02 Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 28 Jul 2020 20:33:29 +0100 Subject: [PATCH 7/8] Stop erroring for packages with large deps --- src/commands/npm.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commands/npm.ts b/src/commands/npm.ts index 062f90e..7a26301 100644 --- a/src/commands/npm.ts +++ b/src/commands/npm.ts @@ -36,6 +36,7 @@ export default class NPM extends Command { let dependencies: string = 'None'; if (version !== 'Unknown' && data.versions[version].dependencies !== undefined && Object.keys(data.versions[version].dependencies).length > 0) { dependencies = Object.keys(data.versions[version].dependencies).join(', '); + if (dependencies.length > 1024) dependencies = `${dependencies.substr(0, 1021)}...`; } const name: string = data.name || 'None'; const repository: string = bugs.replace('/issues', '') || ''; From 600b9ab21d742d4f056c99cbf53ce5e686bfafe7 Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 28 Jul 2020 20:41:26 +0100 Subject: [PATCH 8/8] Add eris docs command --- src/commands/eris.ts | 33 +++++++++++++++++++++++++++++++++ src/commands/index.ts | 1 + 2 files changed, 34 insertions(+) create mode 100644 src/commands/eris.ts diff --git a/src/commands/eris.ts b/src/commands/eris.ts new file mode 100644 index 0000000..f90b8ac --- /dev/null +++ b/src/commands/eris.ts @@ -0,0 +1,33 @@ +import { Message, EmbedOptions } from 'eris'; +import axios, { AxiosResponse, AxiosError } from 'axios'; +import { Client, Command, RichEmbed } from '../class'; + +export default class Eris extends Command { + constructor(client: Client) { + super(client); + this.name = 'eris'; + this.description = 'Get information about Eris.'; + this.usage = 'eris '; + this.permissions = 0; + this.guildOnly = false; + this.enabled = true; + } + + public async run(message: Message, args: string[]) { + try { + if (!args[0]) return this.client.commands.get('help').run(message, [this.name]); + + let res: AxiosResponse<{embed: EmbedOptions}>; + try { + res = await axios.get('https://erisdocs.cloud.libraryofcode.org/docs', { params: { search: args[0] } }); + } catch (err) { + if (err.code === 404) return this.error(message.channel, 'Could not find information. Try something else.'); + return this.error(message.channel, 'Please try again later, something unexpected happened.'); + } + + return message.channel.createMessage(res.data); + } catch (err) { + return this.client.util.handleError(err, message, this); + } + } +} diff --git a/src/commands/index.ts b/src/commands/index.ts index 92b76fc..0f3d8d9 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -8,6 +8,7 @@ export { default as delnote } from './delnote'; export { default as delrank } from './delrank'; export { default as delredirect } from './delredirect'; export { default as djs } from './djs'; +export { default as eris } from './eris'; export { default as eval } from './eval'; export { default as game } from './game'; export { default as help } from './help';