mdn command returns help when no args specified

merge-requests/7/head
DedShot™#9195 2020-05-05 06:55:36 -04:00
parent 933e58051d
commit b9f789e628
1 changed files with 3 additions and 2 deletions

View File

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