diff --git a/Makefile b/Makefile index 39b0916..9db4e9c 100644 --- a/Makefile +++ b/Makefile @@ -10,22 +10,22 @@ all: check_certificate check_cert_signatures storage getUserByUid typescript check_certificate: HOME=/root go build -ldflags="-s -w" -o dist/bin/checkCertificate ${check_certificate_files} @chmod 740 dist/bin/checkCertificate - file dist/bin/checkCertificate + @file dist/bin/checkCertificate check_cert_signatures: HOME=/root go build -ldflags="-s -w" -o dist/bin/checkCertSignatures ${check_certificate_signatures_files} @chmod 740 dist/bin/checkCertSignatures - file dist/bin/checkCertSignatures + @file dist/bin/checkCertSignatures storage: HOME=/root go build -ldflags="-s -w" -buildmode=pie -o dist/bin/storage ${storage_files} @chmod 740 dist/bin/storage - file dist/bin/storage + @file dist/bin/storage getUserByUid: HOME=/root go build -ldflags="-s -w" -o dist/bin/getUserByUid ${get_user_by_uid_files} @chmod 740 dist/bin/getUserByUid - file dist/bin/getUserByUid + @file dist/bin/getUserByUid typescript: tsc -p ./tsconfig.json diff --git a/src/commands/users.ts b/src/commands/users.ts new file mode 100644 index 0000000..2ecabe9 --- /dev/null +++ b/src/commands/users.ts @@ -0,0 +1,74 @@ +/* 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); + } + } +}