Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9,882 changes: 9,882 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,31 @@
"@discordjs/builders": "^1.6.0",
"@discordjs/core": "^1.0.1",
"@discordjs/rest": "^2.0.1",
"@psibean/discord.js-pagination": "^4.0.0",
"canvas": "^2.11.2",
"discord-api-types": "^0.37.61",
"discord.js": "^14.11.0",
"dotenv": "^16.3.1",
"easyqrcodejs-nodejs": "^4.4.0",
"got": "11.8.2",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.21",
"luxon": "^3.3.0",
"node-schedule": "^2.0.0",
"reflect-metadata": "^0.1.13",
"typedi": "^0.10.0",
"typescript": "^5.2.2",
"ucsd-quarters-years": "^1.1.0",
"uuid": "^9.0.1",
"winston": "^3.9.0",
"winston-daily-rotate-file": "^4.7.1"
},
"devDependencies": {
"@types/got": "^9.6.12",
"@types/jsonwebtoken": "^8.5.1",
"@types/lodash": "^4.14.168",
"@types/luxon": "^3.3.0",
"@types/node-schedule": "^1.3.1",
"@types/uuid": "^9.0.5",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
Expand Down
24 changes: 23 additions & 1 deletion src/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { BotSettings, BotClient, BotInitializationError } from './types';
import Command from './Command';
import ActionManager from './managers/ActionManager';
import configuration from './config/config';
import PortalAPIManager from './managers/PortalAPIManager';

/**
* The class representing the Discord bot.
Expand Down Expand Up @@ -36,8 +37,9 @@ export default class Client extends DiscordClient implements BotClient {
*
* Begins the configuration process. Initialization is done in {@link initialize initialize()}.
* @param actionManager An ActionManager class to run. Injected by TypeDI.
* @param portalAPIManager A PortalAPIManager class to run. Injected by TypeDI
*/
constructor(private actionManager: ActionManager) {
constructor(private actionManager: ActionManager, private portalAPIManager: PortalAPIManager) {
super(
configuration.clientOptions || {
intents: [
Expand Down Expand Up @@ -66,6 +68,15 @@ export default class Client extends DiscordClient implements BotClient {
if (!process.env.DISCORD_GUILD_ID) {
throw new BotInitializationError('Discord Guild ID');
}
if (!process.env.MEMBERSHIP_PORTAL_API_URL) {
throw new BotInitializationError('Membership Portal API URL');
}
if (!process.env.MEMBERSHIP_PORTAL_API_USERNAME) {
throw new BotInitializationError('Membership Portal API Username');
}
if (!process.env.MEMBERSHIP_PORTAL_API_PASSWORD) {
throw new BotInitializationError('Membership Portal API Password');
}
if (!process.env.ACMURL_USERNAME) {
throw new BotInitializationError('ACMURL Username');
}
Expand All @@ -79,6 +90,9 @@ export default class Client extends DiscordClient implements BotClient {
this.settings.discordGuildID = process.env.DISCORD_GUILD_ID;
this.settings.acmurl.username = process.env.ACMURL_USERNAME;
this.settings.acmurl.password = process.env.ACMURL_PASSWORD;
this.settings.portalAPI.url = process.env.MEMBERSHIP_PORTAL_API_URL;
this.settings.portalAPI.username = process.env.MEMBERSHIP_PORTAL_API_USERNAME;
this.settings.portalAPI.password = process.env.MEMBERSHIP_PORTAL_API_PASSWORD;
this.initialize().then();
}

Expand All @@ -91,6 +105,7 @@ export default class Client extends DiscordClient implements BotClient {
*/
private async initialize(): Promise<void> {
try {
this.portalAPIManager.initializeTokenHandling(this);
this.actionManager.initializeCommands(this);
ActionManager.initializeEvents(this);
await this.login(configuration.token);
Expand All @@ -107,4 +122,11 @@ export default class Client extends DiscordClient implements BotClient {
public get commands(): Collection<string, Command> {
return this.actionManager.commands;
}

/**
* Get the API token for the Membership Portal API.
*/
public get apiToken(): string {
return this.portalAPIManager.apiToken;
}
}
Loading