fix issues relating to MR \!3

merge-requests/9/merge
Matthew 2020-04-16 09:03:59 -04:00
parent 5c1b99129d
commit e3dd49e3a8
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
1 changed files with 21 additions and 22 deletions

View File

@ -1,4 +1,4 @@
import { Message } from 'eris'; import { Message, Role } from 'eris';
import { Client, Command, RichEmbed } from '../class'; import { Client, Command, RichEmbed } from '../class';
export default class Roleinfo extends Command { export default class Roleinfo extends Command {
@ -6,7 +6,7 @@ export default class Roleinfo extends Command {
super(client); super(client);
this.name = 'roleinfo'; this.name = 'roleinfo';
this.description = 'Get information about a role.'; 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.permissions = 0;
this.guildOnly = true; this.guildOnly = true;
this.enabled = 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.`); 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;
if (!isNaN(args[0])) { // if it's a role id if (!Number.isNaN(args[0])) { // if it's a role id
// @ts-ignore // @ts-ignore
role = message.channel.guild.roles.find((role) => role.id == args[0]); role = message.channel.guild.roles.find((r: Role) => r.id === args[0]);
} else if (isNaN(args[0])) { // if it's a role name } else if (Number.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); 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.`); 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; hasPerms = true;
} }
let embed = new RichEmbed() const embed = new RichEmbed();
embed.setDescription(`<@&${role.id}> ID: \`${role.id}\``) embed.setDescription(`<@&${role.id}> ID: \`${role.id}\``);
embed.setAuthor(`${message.author.username}#${message.author.discriminator}`, message.author.avatarURL) embed.setAuthor(`${message.author.username}#${message.author.discriminator}`, message.author.avatarURL);
embed.setColor(role.color) embed.setColor(role.color);
embed.addField("Name", role.name, true) embed.addField('Name', role.name, true);
embed.addField("Color", `#${role.color.toString(16)}`, true) embed.addField('Color', `#${role.color.toString(16)}`, true);
embed.addField("Hoisted", role.hoist.toString(), true) embed.addField('Hoisted', role.hoist.toString(), true);
embed.addField("Position", role.position.toString(), true) embed.addField('Position', role.position.toString(), true);
embed.addField("Creation Date", `${date} ${time}`, true) embed.addField('Creation Date', `${date} ${time}`, true);
embed.addField("Mentionnable", role.mentionable.toString(), true) embed.addField('Mentionnable', role.mentionable.toString(), true);
embed.setFooter(this.client.user.username, this.client.user.avatarURL) embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp() embed.setTimestamp();
if (hasPerms) { if (hasPerms) {
embed.fields.push({ name: 'Permissions', value: permsArray, inline: false }); embed.fields.push({ name: 'Permissions', value: permsArray, inline: false });
} }
message.channel.createMessage({embed: embed}); return message.channel.createMessage({ embed });
} catch (err) { } 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);
} }
} }
} }