fix merge conflict

pull/29/head
Matthew 2020-07-19 20:10:00 -04:00
commit 7e9a90b1ee
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
5 changed files with 55 additions and 63 deletions

View File

@ -1,22 +1,22 @@
import { Member } from 'eris'; import { Member } from 'eris';
import { Client, Event } from '../class'; import { Client, Event } from '../class';
export default class GuildMemberAdd extends Event { export default class GuildMemberAdd extends Event {
public client: Client; public client: Client;
constructor(client: Client) { constructor(client: Client) {
super(client); super(client);
this.event = 'guildMemberAdd'; this.event = 'guildMemberAdd';
} }
public async run(_, member: Member) { public async run(_, member: Member) {
try { try {
const search = await this.client.db.local.muted.get<boolean>(`muted-${member.user.id}`); const search = await this.client.db.local.muted.get<boolean>(`muted-${member.user.id}`);
if (search === true) { if (search === true) {
member.addRole('478373942638149643'); member.addRole('478373942638149643');
} }
} catch (err) { } catch (err) {
this.client.util.handleError(err); this.client.util.handleError(err);
} }
} }
} }

View File

@ -9,6 +9,7 @@ export default class Ready extends Event {
} }
public async run() { public async run() {
await this.client.loadIntervals();
this.client.util.signale.start(`${this.client.user.username} is now ready!\nServers: ${this.client.guilds.size}\nUsers: ${this.client.users.size}\n\nhttps://gitlab.libraryofcode.org/engineering/communityrelations`); this.client.util.signale.start(`${this.client.user.username} is now ready!\nServers: ${this.client.guilds.size}\nUsers: ${this.client.users.size}\n\nhttps://gitlab.libraryofcode.org/engineering/communityrelations`);
this.client.on('error', (err) => { this.client.on('error', (err) => {
this.client.util.handleError(err); this.client.util.handleError(err);

View File

@ -75,18 +75,18 @@ function logNewPager(client: Client, num: string, member: Member): void {
channel.createMessage(`__**'${member.user.username}#${member.user.discriminator}' assigned to pager number '${num}'.**__`); channel.createMessage(`__**'${member.user.username}#${member.user.discriminator}' assigned to pager number '${num}'.**__`);
} }
export default async function departmentPager(client0: Client): Promise<NodeJS.Timeout> { export default async function departmentPager(client: Client): Promise<NodeJS.Timeout> {
setupDepartmentCodes(client0); setupDepartmentCodes(client);
// eslint-disable-next-line no-shadow
async function start(client: Client) { async function start(client: Client) {
const acknowledgements = require(`${__dirname}/../configs/acknowledgements.json`); const acknowledgements = require(`${__dirname}/../configs/acknowledgements.json`);
function resolveStaffInformation(id: string) { function resolveStaffInformation(id: string) {
return acknowledgements.find((m) => m.id === id); return acknowledgements.find((m) => m.id === id);
} }
// await client.guilds.get(client.config.guildID).fetchAllMembers(); await client.guilds.get(client.config.guildID).fetchAllMembers();
const { members } = client.guilds.get(client.config.guildID); const members = client.guilds.get(client.config.guildID).members.values();
for (let member of members.values()) { for (const member of members) {
member = await client.guilds.get(client.config.guildID).getRESTMember(member.id);
const pager = await client.db.PagerNumber.findOne({ individualAssignID: member.id }).lean().exec(); const pager = await client.db.PagerNumber.findOne({ individualAssignID: member.id }).lean().exec();
if (!pager) continue; if (!pager) continue;
if (pager.num.startsWith('00') && !member.roles.includes('662163685439045632')) { if (pager.num.startsWith('00') && !member.roles.includes('662163685439045632')) {
@ -116,9 +116,7 @@ export default async function departmentPager(client0: Client): Promise<NodeJS.T
} }
// const takenPagers = new Set<string>(); // const takenPagers = new Set<string>();
for (const member of members) {
for (let member of members.values()) {
member = await client.guilds.get(client.config.guildID).getRESTMember(member.id);
let pager = await client.db.PagerNumber.findOne({ individualAssignID: member.id }).lean().exec(); let pager = await client.db.PagerNumber.findOne({ individualAssignID: member.id }).lean().exec();
// Directors // Directors
if (!pager && member.roles.includes('662163685439045632')) { if (!pager && member.roles.includes('662163685439045632')) {
@ -132,14 +130,14 @@ export default async function departmentPager(client0: Client): Promise<NodeJS.T
if (check?.num !== randomPagerNumber) status = false; if (check?.num !== randomPagerNumber) status = false;
} }
const acknowledgement = resolveStaffInformation(member.id); const acknowledgement = resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) return; if (!acknowledgement || !acknowledgement.emailAddress) continue;
const newNumber = new client.db.PagerNumber({ const newNumber = new client.db.PagerNumber({
num: randomPagerNumber, num: randomPagerNumber,
individualAssignID: member.id, individualAssignID: member.id,
emailAddresses: [acknowledgement.emailAddress], emailAddresses: [acknowledgement.emailAddress],
discordIDs: [member.id], discordIDs: [member.id],
}); });
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) return; if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
pager = await newNumber.save(); pager = await newNumber.save();
logNewPager(client, randomPagerNumber, member); logNewPager(client, randomPagerNumber, member);
client.getDMChannel(member.id).then((chan) => { client.getDMChannel(member.id).then((chan) => {
@ -157,14 +155,14 @@ export default async function departmentPager(client0: Client): Promise<NodeJS.T
if (check?.num !== randomPagerNumber) status = false; if (check?.num !== randomPagerNumber) status = false;
} }
const acknowledgement = resolveStaffInformation(member.id); const acknowledgement = resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) return; if (!acknowledgement || !acknowledgement.emailAddress) continue;
const newNumber = new client.db.PagerNumber({ const newNumber = new client.db.PagerNumber({
num: randomPagerNumber, num: randomPagerNumber,
individualAssignID: member.id, individualAssignID: member.id,
emailAddresses: [acknowledgement.emailAddress], emailAddresses: [acknowledgement.emailAddress],
discordIDs: [member.id], discordIDs: [member.id],
}); });
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) return; if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
logNewPager(client, randomPagerNumber, member); logNewPager(client, randomPagerNumber, member);
pager = await newNumber.save(); pager = await newNumber.save();
client.getDMChannel(member.id).then((chan) => { client.getDMChannel(member.id).then((chan) => {
@ -183,14 +181,14 @@ export default async function departmentPager(client0: Client): Promise<NodeJS.T
if (check?.num !== randomPagerNumber) status = false; if (check?.num !== randomPagerNumber) status = false;
} }
const acknowledgement = resolveStaffInformation(member.id); const acknowledgement = resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) return; if (!acknowledgement || !acknowledgement.emailAddress) continue;
const newNumber = new client.db.PagerNumber({ const newNumber = new client.db.PagerNumber({
num: randomPagerNumber, num: randomPagerNumber,
individualAssignID: member.id, individualAssignID: member.id,
emailAddresses: [acknowledgement.emailAddress], emailAddresses: [acknowledgement.emailAddress],
discordIDs: [member.id], discordIDs: [member.id],
}); });
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) return; if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
logNewPager(client, randomPagerNumber, member); logNewPager(client, randomPagerNumber, member);
pager = await newNumber.save(); pager = await newNumber.save();
client.getDMChannel(member.id).then((chan) => { client.getDMChannel(member.id).then((chan) => {
@ -209,14 +207,14 @@ export default async function departmentPager(client0: Client): Promise<NodeJS.T
if (check?.num !== randomPagerNumber) status = false; if (check?.num !== randomPagerNumber) status = false;
} }
const acknowledgement = resolveStaffInformation(member.id); const acknowledgement = resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) return; if (!acknowledgement || !acknowledgement.emailAddress) continue;
const newNumber = new client.db.PagerNumber({ const newNumber = new client.db.PagerNumber({
num: randomPagerNumber, num: randomPagerNumber,
individualAssignID: member.id, individualAssignID: member.id,
emailAddresses: [acknowledgement.emailAddress], emailAddresses: [acknowledgement.emailAddress],
discordIDs: [member.id], discordIDs: [member.id],
}); });
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) return; if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
logNewPager(client, randomPagerNumber, member); logNewPager(client, randomPagerNumber, member);
pager = await newNumber.save(); pager = await newNumber.save();
client.getDMChannel(member.id).then((chan) => { client.getDMChannel(member.id).then((chan) => {
@ -235,14 +233,14 @@ export default async function departmentPager(client0: Client): Promise<NodeJS.T
if (check?.num !== randomPagerNumber) status = false; if (check?.num !== randomPagerNumber) status = false;
} }
const acknowledgement = resolveStaffInformation(member.id); const acknowledgement = resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) return; if (!acknowledgement || !acknowledgement.emailAddress) continue;
const newNumber = new client.db.PagerNumber({ const newNumber = new client.db.PagerNumber({
num: randomPagerNumber, num: randomPagerNumber,
individualAssignID: member.id, individualAssignID: member.id,
emailAddresses: [acknowledgement.emailAddress], emailAddresses: [acknowledgement.emailAddress],
discordIDs: [member.id], discordIDs: [member.id],
}); });
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) return; if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
logNewPager(client, randomPagerNumber, member); logNewPager(client, randomPagerNumber, member);
pager = await newNumber.save(); pager = await newNumber.save();
client.getDMChannel(member.id).then((chan) => { client.getDMChannel(member.id).then((chan) => {
@ -261,14 +259,14 @@ export default async function departmentPager(client0: Client): Promise<NodeJS.T
if (check?.num !== randomPagerNumber) status = false; if (check?.num !== randomPagerNumber) status = false;
} }
const acknowledgement = resolveStaffInformation(member.id); const acknowledgement = resolveStaffInformation(member.id);
if (!acknowledgement || !acknowledgement.emailAddress) return; if (!acknowledgement || !acknowledgement.emailAddress) continue;
const newNumber = new client.db.PagerNumber({ const newNumber = new client.db.PagerNumber({
num: randomPagerNumber, num: randomPagerNumber,
individualAssignID: member.id, individualAssignID: member.id,
emailAddresses: [acknowledgement.emailAddress], emailAddresses: [acknowledgement.emailAddress],
discordIDs: [member.id], discordIDs: [member.id],
}); });
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) return; if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
logNewPager(client, randomPagerNumber, member); logNewPager(client, randomPagerNumber, member);
pager = await newNumber.save(); pager = await newNumber.save();
client.getDMChannel(member.id).then((chan) => { client.getDMChannel(member.id).then((chan) => {
@ -279,8 +277,7 @@ export default async function departmentPager(client0: Client): Promise<NodeJS.T
// Associates // Associates
const associatePagers = await client.db.PagerNumber.findOne({ num: '22' }); const associatePagers = await client.db.PagerNumber.findOne({ num: '22' });
for (let member of members.values()) { for (const member of members) {
member = await client.guilds.get(client.config.guildID).getRESTMember(member.id);
if (member.roles.includes('701481967149121627') && !associatePagers.discordIDs.includes(member.id)) { if (member.roles.includes('701481967149121627') && !associatePagers.discordIDs.includes(member.id)) {
await associatePagers.updateOne({ $addToSet: { discordIDs: member.id } }); await associatePagers.updateOne({ $addToSet: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id); const acknowledgement = resolveStaffInformation(member.id);
@ -294,8 +291,7 @@ export default async function departmentPager(client0: Client): Promise<NodeJS.T
} }
// Core Team // Core Team
const coreTeamPagers = await client.db.PagerNumber.findOne({ num: '21' }); const coreTeamPagers = await client.db.PagerNumber.findOne({ num: '21' });
for (let member of members.values()) { for (const member of members) {
member = await client.guilds.get(client.config.guildID).getRESTMember(member.id);
if (member.roles.includes('453689940140883988') && !coreTeamPagers.discordIDs.includes(member.id)) { if (member.roles.includes('453689940140883988') && !coreTeamPagers.discordIDs.includes(member.id)) {
await coreTeamPagers.updateOne({ $addToSet: { discordIDs: member.id } }); await coreTeamPagers.updateOne({ $addToSet: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id); const acknowledgement = resolveStaffInformation(member.id);
@ -309,8 +305,7 @@ export default async function departmentPager(client0: Client): Promise<NodeJS.T
} }
// Moderator // Moderator
const moderatorPagers = await client.db.PagerNumber.findOne({ num: '20' }); const moderatorPagers = await client.db.PagerNumber.findOne({ num: '20' });
for (let member of members.values()) { for (const member of members) {
member = await client.guilds.get(client.config.guildID).getRESTMember(member.id);
if (member.roles.includes('455972169449734144') && !moderatorPagers.discordIDs.includes(member.id)) { if (member.roles.includes('455972169449734144') && !moderatorPagers.discordIDs.includes(member.id)) {
await moderatorPagers.updateOne({ $addToSet: { discordIDs: member.id } }); await moderatorPagers.updateOne({ $addToSet: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id); const acknowledgement = resolveStaffInformation(member.id);
@ -324,8 +319,7 @@ export default async function departmentPager(client0: Client): Promise<NodeJS.T
} }
// Technician // Technician
const technicianPagers = await client.db.PagerNumber.findOne({ num: '10' }); const technicianPagers = await client.db.PagerNumber.findOne({ num: '10' });
for (let member of members.values()) { for (const member of members) {
member = await client.guilds.get(client.config.guildID).getRESTMember(member.id);
if (member.roles.includes('701454780828221450') && !technicianPagers.discordIDs.includes(member.id)) { if (member.roles.includes('701454780828221450') && !technicianPagers.discordIDs.includes(member.id)) {
await technicianPagers.updateOne({ $addToSet: { discordIDs: member.id } }); await technicianPagers.updateOne({ $addToSet: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id); const acknowledgement = resolveStaffInformation(member.id);
@ -339,8 +333,7 @@ export default async function departmentPager(client0: Client): Promise<NodeJS.T
} }
// Supervisor // Supervisor
const supervisorPagers = await client.db.PagerNumber.findOne({ num: '01' }); const supervisorPagers = await client.db.PagerNumber.findOne({ num: '01' });
for (let member of members.values()) { for (const member of members) {
member = await client.guilds.get(client.config.guildID).getRESTMember(member.id);
if (member.roles.includes('701454855952138300') && !supervisorPagers.discordIDs.includes(member.id)) { if (member.roles.includes('701454855952138300') && !supervisorPagers.discordIDs.includes(member.id)) {
await supervisorPagers.updateOne({ $addToSet: { discordIDs: member.id } }); await supervisorPagers.updateOne({ $addToSet: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id); const acknowledgement = resolveStaffInformation(member.id);
@ -354,8 +347,7 @@ export default async function departmentPager(client0: Client): Promise<NodeJS.T
} }
// Board of Directors // Board of Directors
const directorPagers = await client.db.PagerNumber.findOne({ num: '00' }); const directorPagers = await client.db.PagerNumber.findOne({ num: '00' });
for (let member of members.values()) { for (const member of members) {
member = await client.guilds.get(client.config.guildID).getRESTMember(member.id);
if (member.roles.includes('662163685439045632') && !directorPagers.discordIDs.includes(member.id)) { if (member.roles.includes('662163685439045632') && !directorPagers.discordIDs.includes(member.id)) {
await directorPagers.updateOne({ $addToSet: { discordIDs: member.id } }); await directorPagers.updateOne({ $addToSet: { discordIDs: member.id } });
const acknowledgement = resolveStaffInformation(member.id); const acknowledgement = resolveStaffInformation(member.id);
@ -368,13 +360,13 @@ export default async function departmentPager(client0: Client): Promise<NodeJS.T
} }
} }
} }
client0.util.signale.time('pagerint'); client.util.signale.time('pagerint');
await start(client0); await start(client);
client0.util.signale.timeEnd('pagerint'); client.util.signale.timeEnd('pagerint');
interval = setInterval(async () => { interval = setInterval(async () => {
client0.util.signale.time('pagerint'); client.util.signale.time('pagerint');
await start(client0); await start(client);
client0.util.signale.timeEnd('pagerint'); client.util.signale.timeEnd('pagerint');
}, 300000); }, 300000);
return interval; return interval;
} }

View File

@ -3,7 +3,7 @@ import { Client } from '../class';
let interval: NodeJS.Timeout; let interval: NodeJS.Timeout;
export default async function fetchMembers(client: Client): Promise<NodeJS.Timeout> { export default async function fetchMembers(client: Client): Promise<NodeJS.Timeout> {
await client.guilds.get(client.config.guildID)?.fetchAllMembers(); // await client.guilds.get(client.config.guildID)?.fetchAllMembers();
interval = setInterval(async () => { interval = setInterval(async () => {
// await client.guilds.get(client.config.guildID).fetchAllMembers(); // await client.guilds.get(client.config.guildID).fetchAllMembers();
}, 1800000); }, 1800000);

View File

@ -15,7 +15,6 @@ async function main(): Promise<void> {
client.config = config; client.config = config;
await client.loadDatabase(); await client.loadDatabase();
client.loadPlugins(); client.loadPlugins();
await client.loadIntervals();
await client.loadEvents(eventFiles); await client.loadEvents(eventFiles);
await client.loadCommands(commandFiles); await client.loadCommands(commandFiles);
client.connect(); client.connect();