add t2 application
parent
f70492e059
commit
351b562c7c
|
@ -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)] } });
|
||||
}
|
||||
});
|
||||
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 guild = this.client.guilds.get(job.data.channelInformation.guildID);
|
||||
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.setTimestamp();
|
||||
await channel.createMessage({ content: `<@${job.data.userID}>`, embed });
|
||||
const func = eval(job.data.func);
|
||||
if (application.status === 'SUCCESS' && application.decision === 'APPROVED') await func(this.client, job.data.userID);
|
||||
if (job.data.func) {
|
||||
const func = eval(job.data.func);
|
||||
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 });
|
||||
}
|
||||
|
||||
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 });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
import { Client, RichEmbed } from '.';
|
||||
|
||||
export default class Report {
|
||||
public static async soft(userID: string)
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
import type { AxiosError } from 'axios';
|
||||
import type { AxiosError, AxiosStatic } from 'axios';
|
||||
import axios from 'axios';
|
||||
import { Member, Message } from 'eris';
|
||||
import { Client, Command, RichEmbed } from '../class';
|
||||
|
||||
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) {
|
||||
super(client);
|
||||
|
@ -21,13 +21,37 @@ export default class Apply extends Command {
|
|||
this.services = new Map();
|
||||
this.services.set('role::constants', {
|
||||
description: 'Constants role assignment.',
|
||||
type: 'HARD',
|
||||
url: 'https://eds.libraryofcode.org/roles/constants',
|
||||
validation: (member: Member) => !member.roles.includes('511771731891847168'),
|
||||
func: async (client: Client, ...data: any[]) => {
|
||||
const member = await client.guilds.get('446067825673633794').getRESTMember(data[0]);
|
||||
await member.addRole('511771731891847168');
|
||||
const member = await client.guilds.get(client.config.guildID).getRESTMember(data[0]);
|
||||
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[]) {
|
||||
|
@ -36,7 +60,7 @@ export default class Apply extends Command {
|
|||
const embed = new RichEmbed();
|
||||
embed.setTitle('Available Instant Applications');
|
||||
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.setTimestamp();
|
||||
|
|
Loading…
Reference in New Issue