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] 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) {