add IAS service for Proficients and Regulars
parent
82e9d0498b
commit
e48873a876
|
@ -5,7 +5,7 @@ import { Member, Message } from 'eris';
|
|||
import { Client, Command, RichEmbed } from '../class';
|
||||
|
||||
export default class Apply extends Command {
|
||||
public services: Map<string, { description: string, type: 'HARD' | 'SOFT', url: string, validation: (...cond: any) => Promise<boolean> | boolean, func?: Function }>;
|
||||
public services: Map<string, { description: string, type: 'HARD' | 'SOFT', saaOnly?: boolean, url: string, validation: (...cond: any) => Promise<boolean> | boolean, func?: Function }>;
|
||||
|
||||
constructor(client: Client) {
|
||||
super(client);
|
||||
|
@ -20,6 +20,28 @@ export default class Apply extends Command {
|
|||
|
||||
protected setServices() {
|
||||
this.services = new Map();
|
||||
this.services.set('role::proficient', {
|
||||
description: 'Proficient role assignment.',
|
||||
type: 'HARD',
|
||||
saaOnly: true,
|
||||
url: 'https://eds.libraryofcode.org/roles/proficient',
|
||||
validation: (member: Member) => !member.roles.includes('506943223680466955'),
|
||||
func: async (client: Client, ...data: any[]) => {
|
||||
const member = await client.guilds.get(client.config.guildID).getRESTMember(data[0]);
|
||||
await member.addRole('506943223680466955', 'Proficient Approval from EDS');
|
||||
},
|
||||
});
|
||||
this.services.set('role::regulars', {
|
||||
description: 'Regulars role assignment.',
|
||||
type: 'HARD',
|
||||
saaOnly: true,
|
||||
url: 'https://eds.libraryofcode.org/roles/regulars',
|
||||
validation: (member: Member) => !member.roles.includes('472524444083159050'),
|
||||
func: async (client: Client, ...data: any[]) => {
|
||||
const member = await client.guilds.get(client.config.guildID).getRESTMember(data[0]);
|
||||
await member.addRole('472524444083159050', 'Regulars Approval from EDS');
|
||||
},
|
||||
});
|
||||
this.services.set('role::constants', {
|
||||
description: 'Constants role assignment.',
|
||||
type: 'HARD',
|
||||
|
@ -116,7 +138,7 @@ export default class Apply extends Command {
|
|||
// eslint-disable-next-line no-await-in-loop
|
||||
const test = await service[1].validation(message.member);
|
||||
if (!test && args[0] !== 'full') continue;
|
||||
embed.addField(service[0], `**Description**: ${service[1].description}\n**Inquiry Type:** ${service[1].type}\n\n*Run \`${this.client.config.prefix}apply ${service[0]}\` to apply.*`);
|
||||
embed.addField(service[0], `**Description**: ${service[1].description}\n**Inquiry Type:** ${service[1].type}\n\n${service[1].saaOnly ? '*This application can only be ran as a Staff-Assisted Application and cannot be ran automatically. Please DM <@457750238208327691> to apply.*' : `*Run \`${this.client.config.prefix}apply ${service[0]}\` to apply.*`}`);
|
||||
}
|
||||
if (embed.fields?.length <= 0) embed.setDescription(`*We have no offers for you at this time. To see a full list of offers, please run \`${this.client.config.prefix}apply full\`.*`);
|
||||
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
|
||||
|
@ -128,6 +150,7 @@ export default class Apply extends Command {
|
|||
const service = this.services.get(args[0]);
|
||||
const test = await this.services.get(args[0]).validation(message.member);
|
||||
if (!test) return this.error(message.channel, 'A condition exists which prevents you from applying, please try again later.');
|
||||
if (service.saaOnly) return this.error(message.channel, 'This application can only be ran as a Staff-Assisted Application and cannot be ran automatically. Please DM <@457750238208327691> to apply.');
|
||||
const msg = await this.loading(message.channel, 'Thank you for submitting an application. We are currently processing it, you will be pinged here shortly with the decision.');
|
||||
return await this.client.queue.processApplication({ channelID: message.channel.id, guildID: this.mainGuild.id, messageID: msg.id }, service.url, message.author.id, service.func ? service.func.toString() : undefined);
|
||||
} catch (err) {
|
||||
|
|
Loading…
Reference in New Issue