Added try/catch block
parent
446e6db437
commit
4141482c21
|
@ -11,7 +11,8 @@ export default class Roleinfo extends Command {
|
||||||
this.enabled = true;
|
this.enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async run(message: Message, args: Array<any>) {
|
public async run(message: Message, args: any) {
|
||||||
|
try {
|
||||||
if (!args[0]) return this.client.createMessage(message.channel.id, `${this.client.util.emojis.ERROR} You need to specifiy a role ID or a role name.`);
|
if (!args[0]) return this.client.createMessage(message.channel.id, `${this.client.util.emojis.ERROR} You need to specifiy a role ID or a role name.`);
|
||||||
|
|
||||||
let role: any;
|
let role: any;
|
||||||
|
@ -19,9 +20,11 @@ export default class Roleinfo extends Command {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
role = message.channel.guild.roles.find((role) => role.id == args[0]);
|
role = message.channel.guild.roles.find((role) => role.id == args[0]);
|
||||||
} else if (isNaN(args[0])) { // if it's a role name
|
} else if (isNaN(args[0])) { // if it's a role name
|
||||||
|
args = args.join(' ');
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
role = message.channel.guild.roles.find((role) => role.name == args[0]);
|
role = message.channel.guild.roles.find((role) => role.name == args);
|
||||||
}
|
}
|
||||||
|
if (!role) return this.client.createMessage(message.channel.id, `${this.client.util.emojis.ERROR} Could not find role.`);
|
||||||
|
|
||||||
const ms = role.createdAt;
|
const ms = role.createdAt;
|
||||||
const date = new Date(ms).toLocaleDateString('en-us');
|
const date = new Date(ms).toLocaleDateString('en-us');
|
||||||
|
@ -95,5 +98,8 @@ export default class Roleinfo extends Command {
|
||||||
embed.embed.fields.push({ name: 'Permissions', value: permsArray, inline: false });
|
embed.embed.fields.push({ name: 'Permissions', value: permsArray, inline: false });
|
||||||
}
|
}
|
||||||
message.channel.createMessage(embed);
|
message.channel.createMessage(embed);
|
||||||
|
} catch (err) {
|
||||||
|
this.client.createMessage(message.channel.id, `${this.client.util.emojis.ERROR} An unexpected error has occured.`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue