From 721262f7d37989b26f1d4add27dcbb33fcd35149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DedShot=E2=84=A2=239195?= Date: Mon, 18 May 2020 23:38:53 -0400 Subject: [PATCH 1/4] fixing djs command --- src/commands/djs.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/commands/djs.ts b/src/commands/djs.ts index 224150a..44e6367 100644 --- a/src/commands/djs.ts +++ b/src/commands/djs.ts @@ -17,10 +17,20 @@ export default class DJS extends Command { try { if (!args[0]) return this.client.commands.get('help').run(message, [this.name]); - const { data }: AxiosResponse = await axios.get(`https://djsdocs.sorta.moe/v2/embed?src=master&q=${args[0]}`); + let res: AxiosResponse; + try { + res = await axios.get(`https://djsdocs.sorta.moe/v2/embed?src=master&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 }: AxiosResponse = res; if (!data) return this.error(message.channel, 'Could not find information. Try something else.'); const embed = new RichEmbed(data); + 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); From 5225a2bda2df354cd991e0e9a34c729cbf757223 Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 19 May 2020 17:48:40 -0400 Subject: [PATCH 2/4] Apply suggestion to src/commands/djs.ts --- src/commands/djs.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/commands/djs.ts b/src/commands/djs.ts index 44e6367..c94a0c1 100644 --- a/src/commands/djs.ts +++ b/src/commands/djs.ts @@ -25,10 +25,9 @@ export default class DJS extends Command { return this.client.util.handleError(err, message, this); } - const { data }: AxiosResponse = res; - if (!data) return this.error(message.channel, 'Could not find information. Try something else.'); + if (!res.data) return this.error(message.channel, 'Could not find information. Try something else.'); - const embed = new RichEmbed(data); + const embed = new RichEmbed(res.data); embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setTimestamp(); return message.channel.createMessage({ embed }); From ed9a93715577159cf908408db0ea2d57127e26d3 Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 19 May 2020 17:49:10 -0400 Subject: [PATCH 3/4] Apply suggestion to src/commands/djs.ts --- src/commands/djs.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/djs.ts b/src/commands/djs.ts index c94a0c1..250fa95 100644 --- a/src/commands/djs.ts +++ b/src/commands/djs.ts @@ -17,7 +17,7 @@ export default class DJS extends Command { try { if (!args[0]) return this.client.commands.get('help').run(message, [this.name]); - let res: AxiosResponse; + let res: AxiosResponse; try { res = await axios.get(`https://djsdocs.sorta.moe/v2/embed?src=master&q=${args[0]}`); } catch (err) { From 46c99ef7bf14a1042501cb685c08bb3619b39744 Mon Sep 17 00:00:00 2001 From: Bsian Date: Tue, 19 May 2020 17:49:24 -0400 Subject: [PATCH 4/4] Apply suggestion to src/commands/djs.ts --- src/commands/djs.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/commands/djs.ts b/src/commands/djs.ts index 250fa95..405e0ac 100644 --- a/src/commands/djs.ts +++ b/src/commands/djs.ts @@ -21,8 +21,7 @@ export default class DJS extends Command { try { res = await axios.get(`https://djsdocs.sorta.moe/v2/embed?src=master&q=${args[0]}`); } catch (err) { - this.error(message.channel, 'Please try again later, something unexpected happened.'); - return this.client.util.handleError(err, message, this); + return this.error(message.channel, 'Please try again later, something unexpected happened.'); } if (!res.data) return this.error(message.channel, 'Could not find information. Try something else.');