use jf handler in client

This commit is contained in:
mightypanders 2023-04-16 02:03:39 +02:00
parent 75aae28cbb
commit 901daa4f10

View File

@ -2,25 +2,30 @@ import { ApplicationCommandDataResolvable, Client, ClientOptions, Collection, Ga
import { CommandType } from "../types/commandTypes";
import fs from 'fs'
import { config } from "../configuration";
import { JellyfinHandler } from "../../jellyfin/handler";
import { logger } from "../logger";
export class ExtendedClient extends Client {
private eventFilePath = `${__dirname}/../events`
private commandFilePath = `${__dirname}/../commands`
private jellyfin: JellyfinHandler
public commands: Collection<string, CommandType> = new Collection()
public constructor() {
public constructor(jf: JellyfinHandler) {
const intents: IntentsBitField = new IntentsBitField()
intents.add(IntentsBitField.Flags.GuildMembers, IntentsBitField.Flags.MessageContent, IntentsBitField.Flags.Guilds, IntentsBitField.Flags.DirectMessages)
const options: ClientOptions = { intents }
super(options)
this.jellyfin = jf
}
public start() {
public async start() {
if (process.env.NODE_ENV === 'test') return
const promises: Promise<any>[] = Array()
promises.push(this.registerSlashCommands())
promises.push(this.registerEventCallback())
Promise.all(promises).then(() => {
this.login(config.token)
this.login(config.bot.token)
})
logger.info(`Connected with ${await this.jellyfin.ServerName()}`)
}
private async importFile(filepath: string): Promise<any> {
console.debug(`Importing ${filepath}`)