Skip to content

Commit

Permalink
fix: ChatClient undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
KararTY committed Oct 6, 2022
1 parent dbcf11c commit 8077439
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/Twitch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default class Client {
public readonly packageJSON: any
public token: Token

public ircClient: ChatClient | undefined
public ircClient: ChatClient

public readonly msgs: Map<string, Message | WhMessage> = new Map()
public readonly channels: Map<string, Channel> = new Map()
Expand Down Expand Up @@ -207,7 +207,6 @@ export default class Client {
if (this.ircClient !== undefined) {
this.ircClient.removeAllListeners()
this.ircClient.close()
this.ircClient = undefined
}

// Relogin to chat!
Expand All @@ -233,7 +232,7 @@ export default class Client {
this.ircClient.once('ready', () => {
this.logger.info('Twitch.READY: Successfully connected to Twitch IRC.')
this.ready = true
this.ircClient?.removeListener('ready')
this.ircClient.removeListener('ready')
})

this.ircClient.on('close', (error) => this.onClose(error))
Expand Down Expand Up @@ -297,7 +296,7 @@ export default class Client {
}

public async sendWhisper (user: NameAndId, message: string): Promise<void> {
return await (this.ircClient as ChatClient).whisper(user.name, `${message}`)
return await this.ircClient.whisper(user.name, `${message}`)
}

public joinChannel ({ id, name }: NameAndId): void {
Expand All @@ -311,9 +310,9 @@ export default class Client {
}

public leaveChannel ({ id, name }: NameAndId): void {
this.channels.delete(id);
this.channels.delete(id)

(this.ircClient as ChatClient)
this.ircClient
.part(name)
.then(() =>
this.logger.info(`Twitch.leaveChannel() -> Twitch.PART: ${name}`)
Expand Down

0 comments on commit 8077439

Please sign in to comment.