wrap all commands in try/catch block
parent
bc72e484f8
commit
b194c7e097
|
@ -11,8 +11,12 @@ export default class Ping extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async run(message: Message) {
|
public async run(message: Message) {
|
||||||
const clientStart: number = Date.now();
|
try {
|
||||||
const msg: Message = await message.channel.createMessage('🏓 Pong!');
|
const clientStart: number = Date.now();
|
||||||
msg.edit(`🏓 Pong!\nClient: \`${Date.now() - clientStart}ms\`\nResponse: \`${msg.createdAt - message.createdAt}ms\``);
|
const msg: Message = await message.channel.createMessage('🏓 Pong!');
|
||||||
|
msg.edit(`🏓 Pong!\nClient: \`${Date.now() - clientStart}ms\`\nResponse: \`${msg.createdAt - message.createdAt}ms\``);
|
||||||
|
} catch (err) {
|
||||||
|
this.client.util.handleError(err, message, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,78 +16,82 @@ export default class Whois extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async run(message: Message, args: string[]) {
|
public async run(message: Message, args: string[]) {
|
||||||
let member: Member;
|
try {
|
||||||
if (!args[0]) member = message.member;
|
let member: Member;
|
||||||
else {
|
if (!args[0]) member = message.member;
|
||||||
|
else {
|
||||||
|
// @ts-ignore
|
||||||
|
member = this.client.util.resolveMember(message, args[0], message.channel.guild);
|
||||||
|
if (!member) {
|
||||||
|
return message.channel.createMessage(`***${this.client.util.emojis.ERROR} Member not found.***`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const embed = new RichEmbed();
|
||||||
|
embed.setAuthor(`${member.user.username}#${member.user.discriminator}`, member.user.avatarURL);
|
||||||
|
if (member.roles.includes('453689940140883988')) {
|
||||||
|
embed.setThumbnail('https://static.libraryofcode.org/library_of_code_associate-badge.png');
|
||||||
|
} else if (member.roles.includes('455972169449734144')) {
|
||||||
|
embed.setThumbnail('https://static.libraryofcode.org/library_of_code_sheriff-badge.png');
|
||||||
|
} else if (member.roles.includes('662163685439045632')) {
|
||||||
|
embed.setThumbnail('https://static.libraryofcode.org/library_of_code_marshal-badge.png');
|
||||||
|
} else {
|
||||||
|
embed.setThumbnail(member.avatarURL);
|
||||||
|
}
|
||||||
|
const ackResolve = this.resolveStaffInformation(member.id);
|
||||||
|
let description = '';
|
||||||
|
if (ackResolve?.title && ackResolve?.dept) {
|
||||||
|
description += `${emotes.titleAndDepartment} __**${ackResolve.title}**__, ${ackResolve.dept}\n\n`;
|
||||||
|
}
|
||||||
|
if (ackResolve?.emailAddress) {
|
||||||
|
description += `${emotes.email} ${ackResolve.emailAddress}\n`;
|
||||||
|
}
|
||||||
|
if (ackResolve?.gitlab) {
|
||||||
|
description += `${emotes.gitlab} ${ackResolve.gitlab}\n`;
|
||||||
|
}
|
||||||
|
if (ackResolve?.github) {
|
||||||
|
description += `${emotes.github} ${ackResolve.github}\n`;
|
||||||
|
}
|
||||||
|
if (ackResolve?.bio) {
|
||||||
|
description += `${emotes.bio} *${ackResolve.bio}*\n`;
|
||||||
|
}
|
||||||
|
description += `\n<@${member.id}>`;
|
||||||
|
embed.setDescription(description);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
member = this.client.util.resolveMember(message, args[0], message.channel.guild);
|
for (const role of member.roles.map((r) => message.channel.guild.roles.get(r)).sort((a, b) => b.position - a.position)) {
|
||||||
if (!member) {
|
if (role.color !== 0) {
|
||||||
return message.channel.createMessage(`***${this.client.util.emojis.ERROR} Member not found.***`);
|
embed.setColor(role.color);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
embed.addField('Status', `${member.status[0].toUpperCase()}${member.status.slice(1)}`, true);
|
||||||
const embed = new RichEmbed();
|
embed.addField('Joined At', `${moment(new Date(message.member.joinedAt)).format('dddd, MMMM Do YYYY, h:mm:ss A')} ET`, true);
|
||||||
embed.setAuthor(`${member.user.username}#${member.user.discriminator}`, member.user.avatarURL);
|
embed.addField('Created At', `${moment(new Date(message.author.createdAt)).format('dddd, MMMM Do YYYY, h:mm:ss A')} ET`, true);
|
||||||
if (member.roles.includes('453689940140883988')) {
|
// @ts-ignore
|
||||||
embed.setThumbnail('https://static.libraryofcode.org/library_of_code_associate-badge.png');
|
embed.addField(`Roles [${member.roles.length}]`, member.roles.map((r) => message.channel.guild.roles.get(r)).sort((a, b) => b.position - a.position).map((r) => `<@&${r.id}>`).join(', '));
|
||||||
} else if (member.roles.includes('455972169449734144')) {
|
const permissions: string[] = [];
|
||||||
embed.setThumbnail('https://static.libraryofcode.org/library_of_code_sheriff-badge.png');
|
const bit = member.permission.allow;
|
||||||
} else if (member.roles.includes('662163685439045632')) {
|
if (this.client.guilds.get(this.client.config.guildID).ownerID === member.id) permissions.push('Owner');
|
||||||
embed.setThumbnail('https://static.libraryofcode.org/library_of_code_marshal-badge.png');
|
if ((bit | 8) === bit) permissions.push('Administrator');
|
||||||
} else {
|
if ((bit | 20) === bit) permissions.push('Manage Server');
|
||||||
embed.setThumbnail(member.avatarURL);
|
if ((bit | 10) === bit) permissions.push('Manage Channels');
|
||||||
}
|
if ((bit | 268435456) === bit) permissions.push('Manage Roles');
|
||||||
const ackResolve = this.resolveStaffInformation(member.id);
|
if ((bit | 8192) === bit) permissions.push('Manage Messages');
|
||||||
let description = '';
|
if ((bit | 134217728) === bit) permissions.push('Manage Nicknames');
|
||||||
if (ackResolve?.title && ackResolve?.dept) {
|
if ((bit | 1073741824) === bit) permissions.push('Manage Emojis');
|
||||||
description += `${emotes.titleAndDepartment} __**${ackResolve.title}**__, ${ackResolve.dept}\n\n`;
|
if ((bit | 4) === bit) permissions.push('Ban Members');
|
||||||
}
|
if ((bit | 2) === bit) permissions.push('Kick Members');
|
||||||
if (ackResolve?.emailAddress) {
|
if (permissions.length > 0) {
|
||||||
description += `${emotes.email} ${ackResolve.emailAddress}\n`;
|
embed.addField('Permissions', permissions.join(', '));
|
||||||
}
|
|
||||||
if (ackResolve?.gitlab) {
|
|
||||||
description += `${emotes.gitlab} ${ackResolve.gitlab}\n`;
|
|
||||||
}
|
|
||||||
if (ackResolve?.github) {
|
|
||||||
description += `${emotes.github} ${ackResolve.github}\n`;
|
|
||||||
}
|
|
||||||
if (ackResolve?.bio) {
|
|
||||||
description += `${emotes.bio} *${ackResolve.bio}*\n`;
|
|
||||||
}
|
|
||||||
description += `\n<@${member.id}>`;
|
|
||||||
embed.setDescription(description);
|
|
||||||
// @ts-ignore
|
|
||||||
for (const role of member.roles.map((r) => message.channel.guild.roles.get(r)).sort((a, b) => b.position - a.position)) {
|
|
||||||
if (role.color !== 0) {
|
|
||||||
embed.setColor(role.color);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
if (ackResolve?.acknowledgements) {
|
||||||
|
embed.addField('Bot Acknowledgements', ackResolve.acknowledgements.join(', '));
|
||||||
|
}
|
||||||
|
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
|
||||||
|
embed.setTimestamp();
|
||||||
|
return message.channel.createMessage({ embed });
|
||||||
|
} catch (err) {
|
||||||
|
return this.client.util.handleError(err, message, this);
|
||||||
}
|
}
|
||||||
embed.addField('Status', `${member.status[0].toUpperCase()}${member.status.slice(1)}`, true);
|
|
||||||
embed.addField('Joined At', `${moment(new Date(message.member.joinedAt)).format('dddd, MMMM Do YYYY, h:mm:ss A')} ET`, true);
|
|
||||||
embed.addField('Created At', `${moment(new Date(message.author.createdAt)).format('dddd, MMMM Do YYYY, h:mm:ss A')} ET`, true);
|
|
||||||
// @ts-ignore
|
|
||||||
embed.addField(`Roles [${member.roles.length}]`, member.roles.map((r) => message.channel.guild.roles.get(r)).sort((a, b) => b.position - a.position).map((r) => `<@&${r.id}>`).join(', '));
|
|
||||||
const permissions: string[] = [];
|
|
||||||
const bit = member.permission.allow;
|
|
||||||
if (this.client.guilds.get(this.client.config.guildID).ownerID === member.id) permissions.push('Owner');
|
|
||||||
if ((bit | 8) === bit) permissions.push('Administrator');
|
|
||||||
if ((bit | 20) === bit) permissions.push('Manage Server');
|
|
||||||
if ((bit | 10) === bit) permissions.push('Manage Channels');
|
|
||||||
if ((bit | 268435456) === bit) permissions.push('Manage Roles');
|
|
||||||
if ((bit | 8192) === bit) permissions.push('Manage Messages');
|
|
||||||
if ((bit | 134217728) === bit) permissions.push('Manage Nicknames');
|
|
||||||
if ((bit | 1073741824) === bit) permissions.push('Manage Emojis');
|
|
||||||
if ((bit | 4) === bit) permissions.push('Ban Members');
|
|
||||||
if ((bit | 2) === bit) permissions.push('Kick Members');
|
|
||||||
if (permissions.length > 0) {
|
|
||||||
embed.addField('Permissions', permissions.join(', '));
|
|
||||||
}
|
|
||||||
if (ackResolve?.acknowledgements) {
|
|
||||||
embed.addField('Bot Acknowledgements', ackResolve.acknowledgements.join(', '));
|
|
||||||
}
|
|
||||||
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
|
|
||||||
embed.setTimestamp();
|
|
||||||
return message.channel.createMessage({ embed });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public resolveStaffInformation(id: string) {
|
public resolveStaffInformation(id: string) {
|
||||||
|
|
Loading…
Reference in New Issue