From 80b1d87d387279abcbf1e73b06c4b4038db87a99 Mon Sep 17 00:00:00 2001 From: Bsian Date: Mon, 21 Oct 2019 00:39:49 +0100 Subject: [PATCH] Lint --- src/commands/help.ts | 86 ++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/src/commands/help.ts b/src/commands/help.ts index 412700a..a151e0f 100644 --- a/src/commands/help.ts +++ b/src/commands/help.ts @@ -18,52 +18,52 @@ export default class Help extends Command { public async run(message: Message, args?: string[]) { try { const cmd = args.filter((c) => c)[0]; - if (!cmd) { - const cmdList: Command[] = []; - this.client.commands.forEach((c) => cmdList.push(c)); - const commands = cmdList.map((c) => { - const aliases = c.aliases.map((alias) => `${config.prefix}${alias}`).join(', '); - const perms: string[] = []; - let allowedRoles = c.permissions && c.permissions.roles && c.permissions.roles.map((r) => `<@&${r}>`).join(', '); - if (allowedRoles) { allowedRoles = `**Roles:** ${allowedRoles}`; perms.push(allowedRoles); } - let allowedUsers = c.permissions && c.permissions.users && c.permissions.users.map((u) => `<@${u}>`).join(', '); - if (allowedUsers) { allowedUsers = `**Users:** ${allowedUsers}`; perms.push(allowedUsers); } - const displayedPerms = perms.length ? `**Permissions:**\n${perms.join('\n')}` : ''; - return { name: `${config.prefix}${c.name}`, value: `**Description:** ${c.description}\n**Aliases:** ${aliases}\n**Usage:** ${c.usage}\n${displayedPerms}`, inline: true }; - }); + if (!cmd) { + const cmdList: Command[] = []; + this.client.commands.forEach((c) => cmdList.push(c)); + const commands = cmdList.map((c) => { + const aliases = c.aliases.map((alias) => `${config.prefix}${alias}`).join(', '); + const perms: string[] = []; + let allowedRoles = c.permissions && c.permissions.roles && c.permissions.roles.map((r) => `<@&${r}>`).join(', '); + if (allowedRoles) { allowedRoles = `**Roles:** ${allowedRoles}`; perms.push(allowedRoles); } + let allowedUsers = c.permissions && c.permissions.users && c.permissions.users.map((u) => `<@${u}>`).join(', '); + if (allowedUsers) { allowedUsers = `**Users:** ${allowedUsers}`; perms.push(allowedUsers); } + const displayedPerms = perms.length ? `**Permissions:**\n${perms.join('\n')}` : ''; + return { name: `${config.prefix}${c.name}`, value: `**Description:** ${c.description}\n**Aliases:** ${aliases}\n**Usage:** ${c.usage}\n${displayedPerms}`, inline: true }; + }); - const splitCommands = this.util.splitFields(commands); - const cmdPages: RichEmbed[] = []; - splitCommands.forEach((splitCmd) => { - const embed = new RichEmbed(); - embed.setTimestamp(); embed.setFooter(`Requested by ${message.author.username}#${message.author.discriminator}`, message.author.avatarURL); - embed.setAuthor(`${this.client.user.username}#${this.client.user.discriminator}`, this.client.user.avatarURL); - embed.setDescription(`Command list for ${this.client.user.username}`); - splitCmd.forEach((c) => embed.addField(c.name, c.value, c.inline)); - return cmdPages.push(embed); - }); + const splitCommands = this.util.splitFields(commands); + const cmdPages: RichEmbed[] = []; + splitCommands.forEach((splitCmd) => { + const embed = new RichEmbed(); + embed.setTimestamp(); embed.setFooter(`Requested by ${message.author.username}#${message.author.discriminator}`, message.author.avatarURL); + embed.setAuthor(`${this.client.user.username}#${this.client.user.discriminator}`, this.client.user.avatarURL); + embed.setDescription(`Command list for ${this.client.user.username}`); + splitCmd.forEach((c) => embed.addField(c.name, c.value, c.inline)); + return cmdPages.push(embed); + }); + // @ts-ignore + if (cmdPages.length === 1) return message.channel.createMessage({ embed: cmdPages[0] }); + return createPaginationEmbed(message, this.client, cmdPages); + } + const foundCommand = this.util.resolveCommand(cmd); + if (!foundCommand) return message.channel.createMessage(`${this.client.stores.emojis.error} **Command not found!**`); + const perms: string[] = []; + let allowedRoles = foundCommand.permissions && foundCommand.permissions.roles && foundCommand.permissions.roles.map((r) => `<@&${r}>`).join(', '); + if (allowedRoles) { allowedRoles = `**Roles:** ${allowedRoles}`; perms.push(allowedRoles); } + let allowedUsers = foundCommand.permissions && foundCommand.permissions.users && foundCommand.permissions.users.map((u) => `<@${u}>`).join(', '); + if (allowedUsers) { allowedUsers = `**Users:** ${allowedUsers}`; perms.push(allowedUsers); } + const displayedPerms = perms.length ? `**Permissions:**\n${perms.join('\n')}` : ''; + const aliases = foundCommand.aliases.map((alias) => `${config.prefix}${alias}`).join(', '); + const embed = new RichEmbed(); + embed.setTimestamp(); embed.setFooter(`Requested by ${message.author.username}#${message.author.discriminator}`, message.author.avatarURL); + embed.setTitle(`${config.prefix}${foundCommand.name}`); embed.setAuthor(`${this.client.user.username}#${this.client.user.discriminator}`, this.client.user.avatarURL); + const description = `**Description**: ${foundCommand.description}\n**Usage:** ${foundCommand.usage}\n**Aliases:** ${aliases}\n**Permissions**: ${displayedPerms}`; + embed.setDescription(description); // @ts-ignore - if (cmdPages.length === 1) return message.channel.createMessage({ embed: cmdPages[0] }); - return createPaginationEmbed(message, this.client, cmdPages); - } - const foundCommand = this.util.resolveCommand(cmd); - if (!foundCommand) return message.channel.createMessage(`${this.client.stores.emojis.error} **Command not found!**`); - const perms: string[] = []; - let allowedRoles = foundCommand.permissions && foundCommand.permissions.roles && foundCommand.permissions.roles.map((r) => `<@&${r}>`).join(', '); - if (allowedRoles) { allowedRoles = `**Roles:** ${allowedRoles}`; perms.push(allowedRoles); } - let allowedUsers = foundCommand.permissions && foundCommand.permissions.users && foundCommand.permissions.users.map((u) => `<@${u}>`).join(', '); - if (allowedUsers) { allowedUsers = `**Users:** ${allowedUsers}`; perms.push(allowedUsers); } - const displayedPerms = perms.length ? `**Permissions:**\n${perms.join('\n')}` : ''; - const aliases = foundCommand.aliases.map((alias) => `${config.prefix}${alias}`).join(', '); - const embed = new RichEmbed(); - embed.setTimestamp(); embed.setFooter(`Requested by ${message.author.username}#${message.author.discriminator}`, message.author.avatarURL); - embed.setTitle(`${config.prefix}${foundCommand.name}`); embed.setAuthor(`${this.client.user.username}#${this.client.user.discriminator}`, this.client.user.avatarURL); - const description = `**Description**: ${foundCommand.description}\n**Usage:** ${foundCommand.usage}\n**Aliases:** ${aliases}\n**Permissions**: ${displayedPerms}`; - embed.setDescription(description); - // @ts-ignore - return message.channel.createMessage({ embed }); + return message.channel.createMessage({ embed }); } catch (error) { - this.util.handleError(error, message, this) + return this.util.handleError(error, message, this); } } }