/* eslint-disable no-await-in-loop */ import { Message } from 'eris'; import { createPaginationEmbed } from 'eris-pagination'; import { Client, Command, RichEmbed } from '../class'; export default class Users extends Command { constructor(client: Client) { super(client); this.name = 'users'; this.description = 'Pulls up users.'; this.usage = `${this.client.config.prefix}users \n${fingerInformation}\nTier: ${account.tier} | Email Address: ${account.emailAddress}${account.locked ? ' | Locked: true' : ''}` }); } } else { switch (args[0]) { default: return msg.edit(`***${this.client.stores.emojis.error} Invalid filter option.***`); case 't1': for (const account of accounts.filter((a) => a.tier === 1)) { const fingerInformation = await this.client.util.exec(`finger ${account.username}`); embedFields.push({ name: `${account.username}`, value: `<@${account.userID}>\n${fingerInformation}\nTier: ${account.tier} | Email Address: ${account.emailAddress}${account.locked ? ' | Locked: true' : ''}` }); } break; case 't2': for (const account of accounts.filter((a) => a.tier === 2)) { const fingerInformation = await this.client.util.exec(`finger ${account.username}`); embedFields.push({ name: `${account.username}`, value: `<@${account.userID}>\n${fingerInformation}\nTier: ${account.tier} | Email Address: ${account.emailAddress}${account.locked ? ' | Locked: true' : ''}` }); } break; case 't3': for (const account of accounts.filter((a) => a.tier === 3)) { const fingerInformation = await this.client.util.exec(`finger ${account.username}`); embedFields.push({ name: `${account.username}`, value: `<@${account.userID}>\n${fingerInformation}\nTier: ${account.tier} | Email Address: ${account.emailAddress}${account.locked ? ' | Locked: true' : ''}` }); } break; } } const data = this.client.util.splitFields(embedFields); const embeds = data.map((l) => { const embed = new RichEmbed(); embed.setAuthor('Library of Code | Cloud Services', this.client.user.avatarURL, 'https://libraryofcode.org/'); embed.setTitle('Cloud Accounts'); embed.setFooter(`Requested by ${message.author.username}#${message.author.discriminator}`, message.author.avatarURL); l.forEach((f) => embed.addField(f.name, f.value, true)); embed.setTimestamp(); embed.setColor(3447003); return embed; }); if (embeds.length === 1) { msg.edit({ content: '', embed: embeds[0] }); } else { createPaginationEmbed(message, embeds, {}); } return msg; } catch (error) { return this.client.util.handleError(error, message, this); } } }