Skip to content
This repository has been archived by the owner on Oct 12, 2024. It is now read-only.

Commit

Permalink
Client: Move interatioc & event registration to constructor, hook eve…
Browse files Browse the repository at this point in the history
…nts at login
  • Loading branch information
RadiatedExodus committed Feb 13, 2024
1 parent a5ad2e8 commit 94cdf4c
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/classes/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Client } from "discord.js";
import { Client, ClientOptions } from "discord.js";
import { config } from "dotenv";
import { PrismaClient } from "@prisma/client";
import { HolodexApiClient } from "holodex.js";
Expand Down Expand Up @@ -27,12 +27,24 @@ export default class MeteoriumClient extends Client<true> {
public events = new MeteoriumEventManager(this);
public holodex = new HolodexApiClient({ apiKey: this.config.HolodexApiKey });

public async login() {
const loginNS = this.logging.getNamespace("Login");
public constructor(options: ClientOptions) {
super(options);

// Register all events and hook them
this.events.register();

// Register all interactions
this.interactions.registerAllInteractions();

return this;
}

public async login() {
const loginNS = this.logging.getNamespace("Login");

// Hook events
this.events.hook();

// Login
loginNS.info("Logging in to Discord");
return super.login(this.config.BotToken);
Expand Down

0 comments on commit 94cdf4c

Please sign in to comment.