Skip to content

Commit

Permalink
fix: fix expiring auths not being recognized
Browse files Browse the repository at this point in the history
  • Loading branch information
Snazzah committed Jul 21, 2024
1 parent d6a74cc commit a199c55
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,17 @@ export default abstract class Command extends SlashCommand {
reportErrorFromCommand(ctx, err, this.commandName, 'autocomplete');
}

async onError(err: Error, ctx: CommandContext) {
if ('response' in err) {
const response = (err as any).response as AxiosResponse;
if (response.status === 401 && response.data === 'invalid token') {
const userData = await prisma.user.update({
where: { userID: ctx.user.id },
data: { trelloID: null, trelloToken: null }
});
const t = createT(userData?.locale);
return ctx.send(t('auth.expired'), { components: noAuthResponse(t).components });
}
async onError(err: Error & { response?: AxiosResponse; status?: number; data?: any }, ctx: CommandContext) {
if (
('response' in err && err.response.status === 401 && err.response.data === 'invalid token') ||
(err.status === 401 && err.data === 'invalid token')
) {
const userData = await prisma.user.update({
where: { userID: ctx.user.id },
data: { trelloID: null, trelloToken: null }
});
const t = createT(userData?.locale);
return ctx.send(t('auth.expired'), { components: noAuthResponse(t).components });
}

reportErrorFromCommand(ctx, err, ctx.commandName, 'command');
Expand Down

0 comments on commit a199c55

Please sign in to comment.