1
0
Fork 0
refactor/models
Matthew 2020-11-07 04:45:49 -05:00
parent bf98b85987
commit fc268fa507
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
2 changed files with 78 additions and 4 deletions

View File

@ -10,22 +10,22 @@ all: check_certificate check_cert_signatures storage getUserByUid typescript
check_certificate: check_certificate:
HOME=/root go build -ldflags="-s -w" -o dist/bin/checkCertificate ${check_certificate_files} HOME=/root go build -ldflags="-s -w" -o dist/bin/checkCertificate ${check_certificate_files}
@chmod 740 dist/bin/checkCertificate @chmod 740 dist/bin/checkCertificate
file dist/bin/checkCertificate @file dist/bin/checkCertificate
check_cert_signatures: check_cert_signatures:
HOME=/root go build -ldflags="-s -w" -o dist/bin/checkCertSignatures ${check_certificate_signatures_files} HOME=/root go build -ldflags="-s -w" -o dist/bin/checkCertSignatures ${check_certificate_signatures_files}
@chmod 740 dist/bin/checkCertSignatures @chmod 740 dist/bin/checkCertSignatures
file dist/bin/checkCertSignatures @file dist/bin/checkCertSignatures
storage: storage:
HOME=/root go build -ldflags="-s -w" -buildmode=pie -o dist/bin/storage ${storage_files} HOME=/root go build -ldflags="-s -w" -buildmode=pie -o dist/bin/storage ${storage_files}
@chmod 740 dist/bin/storage @chmod 740 dist/bin/storage
file dist/bin/storage @file dist/bin/storage
getUserByUid: getUserByUid:
HOME=/root go build -ldflags="-s -w" -o dist/bin/getUserByUid ${get_user_by_uid_files} HOME=/root go build -ldflags="-s -w" -o dist/bin/getUserByUid ${get_user_by_uid_files}
@chmod 740 dist/bin/getUserByUid @chmod 740 dist/bin/getUserByUid
file dist/bin/getUserByUid @file dist/bin/getUserByUid
typescript: typescript:
tsc -p ./tsconfig.json tsc -p ./tsconfig.json

74
src/commands/users.ts Normal file
View File

@ -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 <filter: t1 | t2 | t3`;
this.enabled = true;
this.permissions = { roles: ['662163685439045632', '701454780828221450'] };
}
public async run(message: Message, args: string[]) {
try {
const msg: Message = await this.loading(message.channel, 'Locating users...');
const embedFields: [ { name: string, value: string }? ] = [];
const accounts = await this.client.db.Account.find().lean().exec();
if (!args[0]) {
for (const account of accounts) {
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' : ''}` });
}
} 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);
}
}
}