add t2 application

pull/29/head
Matthew 2020-10-31 02:27:41 -04:00
parent f70492e059
commit 351b562c7c
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
3 changed files with 40 additions and 9 deletions

View File

@ -58,7 +58,7 @@ export default class Queue {
await this.client.db.Score.updateOne({ userID: job.data.score.userID }, { $set: { pin: [this.client.util.randomNumber(100, 999), this.client.util.randomNumber(10, 99), this.client.util.randomNumber(1000, 9999)] } }); await this.client.db.Score.updateOne({ userID: job.data.score.userID }, { $set: { pin: [this.client.util.randomNumber(100, 999), this.client.util.randomNumber(10, 99), this.client.util.randomNumber(1000, 9999)] } });
} }
}); });
this.queues.score.process('score::apply', async (job: Bull.Job<{ channelInformation: { messageID: string, guildID: string, channelID: string }, url: string, userID: string, func: string }>) => { this.queues.score.process('score::apply', async (job: Bull.Job<{ channelInformation: { messageID: string, guildID: string, channelID: string }, url: string, userID: string, func?: string }>) => {
const application = await Apply.apply(this.client, job.data.url, job.data.userID); const application = await Apply.apply(this.client, job.data.url, job.data.userID);
const guild = this.client.guilds.get(job.data.channelInformation.guildID); const guild = this.client.guilds.get(job.data.channelInformation.guildID);
const channel = <TextableChannel> guild.channels.get(job.data.channelInformation.channelID); const channel = <TextableChannel> guild.channels.get(job.data.channelInformation.channelID);
@ -72,8 +72,10 @@ export default class Queue {
embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp(); embed.setTimestamp();
await channel.createMessage({ content: `<@${job.data.userID}>`, embed }); await channel.createMessage({ content: `<@${job.data.userID}>`, embed });
if (job.data.func) {
const func = eval(job.data.func); const func = eval(job.data.func);
if (application.status === 'SUCCESS' && application.decision === 'APPROVED') await func(this.client, job.data.userID); if (application.status === 'SUCCESS' && application.decision === 'APPROVED') await func(this.client, job.data.userID);
}
}); });
} }
@ -81,7 +83,7 @@ export default class Queue {
this.queues.score.add('score::update', { score, total, activity, roles, moderation, cloudServices, other, staff }); this.queues.score.add('score::update', { score, total, activity, roles, moderation, cloudServices, other, staff });
} }
public processApplication(channelInformation: { messageID: string, guildID: string, channelID: string }, url: string, userID: string, func: string) { public processApplication(channelInformation: { messageID: string, guildID: string, channelID: string }, url: string, userID: string, func?: string) {
return this.queues.score.add('score::apply', { channelInformation, url, userID, func }); return this.queues.score.add('score::apply', { channelInformation, url, userID, func });
} }
} }

5
src/class/Report.ts Normal file
View File

@ -0,0 +1,5 @@
import { Client, RichEmbed } from '.';
export default class Report {
public static async soft(userID: string)
}

View File

@ -1,10 +1,10 @@
import type { AxiosError } from 'axios'; import type { AxiosError, AxiosStatic } from 'axios';
import axios from 'axios'; import axios from 'axios';
import { Member, Message } from 'eris'; import { Member, Message } from 'eris';
import { Client, Command, RichEmbed } from '../class'; import { Client, Command, RichEmbed } from '../class';
export default class Apply extends Command { export default class Apply extends Command {
public services: Map<string, { description: string, url: string, validation: (...cond: any) => Promise<boolean> | boolean, func: Function }>; public services: Map<string, { description: string, type: 'HARD' | 'SOFT', url: string, validation: (...cond: any) => Promise<boolean> | boolean, func?: Function }>;
constructor(client: Client) { constructor(client: Client) {
super(client); super(client);
@ -21,13 +21,37 @@ export default class Apply extends Command {
this.services = new Map(); this.services = new Map();
this.services.set('role::constants', { this.services.set('role::constants', {
description: 'Constants role assignment.', description: 'Constants role assignment.',
type: 'HARD',
url: 'https://eds.libraryofcode.org/roles/constants', url: 'https://eds.libraryofcode.org/roles/constants',
validation: (member: Member) => !member.roles.includes('511771731891847168'), validation: (member: Member) => !member.roles.includes('511771731891847168'),
func: async (client: Client, ...data: any[]) => { func: async (client: Client, ...data: any[]) => {
const member = await client.guilds.get('446067825673633794').getRESTMember(data[0]); const member = await client.guilds.get(client.config.guildID).getRESTMember(data[0]);
await member.addRole('511771731891847168'); await member.addRole('511771731891847168', 'Constants Approval from EDS');
}, },
}); });
this.services.set('cs::t2', {
description: 'Tier 2 upgrade for Cloud Services account.',
type: 'HARD',
url: 'https://eds.libraryofcode.org/cs/t2',
validation: (member: Member) => !member.roles.includes('546457886440685578'),
func: async (client: Client, ...data: any[]) => {
const member = await client.guilds.get(client.config.guildID).getRESTMember(data[0]);
const ax = <AxiosStatic> require('axios');
await ax({
method: 'get',
url: `https://api.libraryofcode.org/wh/t2?userID=${member.id}&auth=${client.config.internalKey}`,
});
},
});
/* this.services.set('cs::t2', {
description: 'Pre-approval for Tier 2.',
type: 'SOFT',
url: 'https://eds.libraryofcode.org/cs/t2pre-get',
validation: (member: Member) => !member.roles.includes('546457886440685578'),
});
*/
} }
public async run(message: Message, args: string[]) { public async run(message: Message, args: string[]) {
@ -36,7 +60,7 @@ export default class Apply extends Command {
const embed = new RichEmbed(); const embed = new RichEmbed();
embed.setTitle('Available Instant Applications'); embed.setTitle('Available Instant Applications');
for (const service of this.services) { for (const service of this.services) {
embed.addField(service[0], `${service[1].description} | Run \`${this.client.config.prefix}apply ${service[0]}\` to apply.`, true); embed.addField(service[0], `__**Description**__\n${service[1].description}\n__**Inquiry Type:**__\n${service[1].type}\n\n*Run \`${this.client.config.prefix}apply ${service[0]}\` to apply.*`, 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();