used await instead of .then().catch() (KhaaZ)
parent
aafed2980c
commit
89f780ddfb
|
@ -17,35 +17,35 @@ export default class DJS extends Command {
|
||||||
try {
|
try {
|
||||||
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
||||||
|
|
||||||
return axios.get(`https://djsdocs.sorta.moe/v2/embed?src=master&q=${args[0]}`)
|
let res;
|
||||||
.then((res) => {
|
try {
|
||||||
const { data } = res;
|
res = await axios.get(`https://djsdocs.sorta.moe/v2/embed?src=master&q=${args[0]}`);
|
||||||
if (!data) return this.error(message.channel, 'Could not find information. Try something else.');
|
} catch (err) {
|
||||||
|
this.error(message.channel, 'Please try again later, something unexpected happened.');
|
||||||
|
return this.client.util.handleError(err, message, this);
|
||||||
|
}
|
||||||
|
const { data } = res;
|
||||||
|
if (!data) return this.error(message.channel, 'Could not find information. Try something else.');
|
||||||
|
|
||||||
const name: string = data.author?.name || '';
|
const name: string = data.author?.name || '';
|
||||||
const icon_url: string = data.author?.icon_url || '';
|
const icon_url: string = data.author?.icon_url || '';
|
||||||
const author_url: string = data.author?.url || '';
|
const author_url: string = data.author?.url || '';
|
||||||
const description: string = data.description || 'None';
|
const description: string = data.description || 'None';
|
||||||
const title: string = data.title || '';
|
const title: string = data.title || '';
|
||||||
|
|
||||||
const embed = new RichEmbed();
|
const embed = new RichEmbed();
|
||||||
embed.setAuthor(name, icon_url, author_url);
|
embed.setAuthor(name, icon_url, author_url);
|
||||||
embed.setColor(0x2296f3);
|
embed.setColor(0x2296f3);
|
||||||
embed.setTitle(title);
|
embed.setTitle(title);
|
||||||
embed.setDescription(description);
|
embed.setDescription(description);
|
||||||
if (data.fields !== undefined && data.fields.length > 0) {
|
if (data.fields !== undefined && data.fields.length > 0) {
|
||||||
data.fields.forEach((field) => {
|
data.fields.forEach((field) => {
|
||||||
embed.addField(field.name, field.value);
|
embed.addField(field.name, field.value);
|
||||||
});
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
|
||||||
|
embed.setTimestamp();
|
||||||
|
return message.channel.createMessage({ embed });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
return this.client.util.handleError(err, message, this);
|
return this.client.util.handleError(err, message, this);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue