use jf handler in client
This commit is contained in:
parent
75aae28cbb
commit
901daa4f10
|
@ -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}`)
|
||||
|
@ -65,7 +70,7 @@ export class ExtendedClient extends Client {
|
|||
}
|
||||
}
|
||||
public async cacheUsers(guilds: Collection<Snowflake, Guild>) {
|
||||
guilds.forEach((guild:Guild, id:Snowflake) => {
|
||||
guilds.forEach((guild: Guild, id: Snowflake) => {
|
||||
console.log(`Fetching members for ${guild.name}|${id}`)
|
||||
guild.members.fetch()
|
||||
console.log(`Fetched: ${guild.memberCount} members`)
|
||||
|
|
Loading…
Reference in New Issue