mdn command returns help when no args specified
parent
933e58051d
commit
b9f789e628
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue