From e3dd49e3a8311f205394ff0b4716560ac914aeff Mon Sep 17 00:00:00 2001 From: Matthew R Date: Thu, 16 Apr 2020 09:03:59 -0400 Subject: [PATCH] fix issues relating to MR \!3 --- src/commands/roleinfo.ts | 43 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/commands/roleinfo.ts b/src/commands/roleinfo.ts index a55df68..3c196f0 100644 --- a/src/commands/roleinfo.ts +++ b/src/commands/roleinfo.ts @@ -1,4 +1,4 @@ -import { Message } from 'eris'; +import { Message, Role } from 'eris'; import { Client, Command, RichEmbed } from '../class'; export default class Roleinfo extends Command { @@ -6,7 +6,7 @@ export default class Roleinfo extends Command { super(client); this.name = 'roleinfo'; this.description = 'Get information about a role.'; - this.usage = "roleinfo [role ID or role name]" + this.usage = 'roleinfo [role ID or role name]'; this.permissions = 0; this.guildOnly = true; this.enabled = true; @@ -17,13 +17,12 @@ export default class Roleinfo extends Command { 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; - if (!isNaN(args[0])) { // if it's a role id + if (!Number.isNaN(args[0])) { // if it's a role id // @ts-ignore - role = message.channel.guild.roles.find((role) => role.id == args[0]); - } else if (isNaN(args[0])) { // if it's a role name - args = args.join(' '); + role = message.channel.guild.roles.find((r: Role) => r.id === args[0]); + } else if (Number.isNaN(args[0])) { // if it's a role name // @ts-ignore - role = message.channel.guild.roles.find((role) => role.name == args); + role = message.channel.guild.roles.find((r: Role) => r.name === args.join(' ')); } if (!role) return this.client.createMessage(message.channel.id, `${this.client.util.emojis.ERROR} Could not find role.`); @@ -49,25 +48,25 @@ export default class Roleinfo extends Command { hasPerms = true; } - let embed = new RichEmbed() - embed.setDescription(`<@&${role.id}> ID: \`${role.id}\``) - embed.setAuthor(`${message.author.username}#${message.author.discriminator}`, message.author.avatarURL) - embed.setColor(role.color) - embed.addField("Name", role.name, true) - embed.addField("Color", `#${role.color.toString(16)}`, true) - embed.addField("Hoisted", role.hoist.toString(), true) - embed.addField("Position", role.position.toString(), true) - embed.addField("Creation Date", `${date} ${time}`, true) - embed.addField("Mentionnable", role.mentionable.toString(), true) - embed.setFooter(this.client.user.username, this.client.user.avatarURL) - embed.setTimestamp() - + const embed = new RichEmbed(); + embed.setDescription(`<@&${role.id}> ID: \`${role.id}\``); + embed.setAuthor(`${message.author.username}#${message.author.discriminator}`, message.author.avatarURL); + embed.setColor(role.color); + embed.addField('Name', role.name, true); + embed.addField('Color', `#${role.color.toString(16)}`, true); + embed.addField('Hoisted', role.hoist.toString(), true); + embed.addField('Position', role.position.toString(), true); + embed.addField('Creation Date', `${date} ${time}`, true); + embed.addField('Mentionnable', role.mentionable.toString(), true); + embed.setFooter(this.client.user.username, this.client.user.avatarURL); + embed.setTimestamp(); + if (hasPerms) { embed.fields.push({ name: 'Permissions', value: permsArray, inline: false }); } - message.channel.createMessage({embed: embed}); + return message.channel.createMessage({ embed }); } catch (err) { - this.client.createMessage(message.channel.id, `${this.client.util.emojis.ERROR} An unexpected error has occured.`); + return this.client.util.handleError(err, message, this); } } }