Skip to content

Commit

Permalink
correctly recognize join failures
Browse files Browse the repository at this point in the history
  • Loading branch information
d-fischer committed Jan 31, 2022
1 parent ebd5b1a commit 884e9df
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/chat/src/ChatClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ export class ChatClient extends IrcClient {
});
timer = setTimeout(() => {
this.removeListener(e);
this.emit(this._onJoinResult, channel, undefined, 'twurple_timeout');
reject(
new Error(`Did not receive a reply to join ${channel} in time; assuming that the join failed`)
);
Expand Down Expand Up @@ -795,8 +796,10 @@ export class ChatClient extends IrcClient {
await this.join(channel);
} catch (e) {
this._chatLogger.warn(
// TODO this error should always throw an Error instance,
// currently it sometimes rejects with a string
`Failed to join configured channel ${channel}; original message: ${
(e as Error).message
(e as Error | null)?.message ?? (e as string)
}`
);
}
Expand Down Expand Up @@ -1247,7 +1250,8 @@ export class ChatClient extends IrcClient {
}

// join (success is handled when ROOMSTATE comes in)
case 'msg_channel_suspended': {
case 'msg_channel_suspended':
case 'msg_banned': {
this.emit(this._onJoinResult, channel, undefined, messageType);
break;
}
Expand Down Expand Up @@ -1487,8 +1491,7 @@ export class ChatClient extends IrcClient {
case 'msg_verified_email':
case 'msg_timed_out':
case 'msg_rejected_mandatory':
case 'msg_channel_blocked':
case 'msg_banned': {
case 'msg_channel_blocked': {
this.emit(this.onMessageFailed, channel, messageType);
break;
}
Expand Down

0 comments on commit 884e9df

Please sign in to comment.