Fix error when fetching unknown user
This commit is contained in:
parent
88ed1d9313
commit
89ce0555a7
1 changed files with 9 additions and 5 deletions
|
@ -187,11 +187,15 @@ export class ModActionsPlugin extends ZeppelinPlugin<IModActionsPluginConfig> {
|
||||||
userId = userResolvable;
|
userId = userResolvable;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
const cachedUser = this.bot.users.find(u => u.id === userId);
|
||||||
this.bot.users.find(u => u.id === userId) ||
|
if (cachedUser) return cachedUser;
|
||||||
(await this.bot.getRESTUser(userId)) ||
|
|
||||||
createUnknownUser({ id: userId })
|
try {
|
||||||
);
|
const freshUser = await this.bot.getRESTUser(userId);
|
||||||
|
return freshUser;
|
||||||
|
} catch (e) {} // tslint:disable-line
|
||||||
|
|
||||||
|
return createUnknownUser({ id: userId });
|
||||||
}
|
}
|
||||||
|
|
||||||
async getMember(userId: string): Promise<Member> {
|
async getMember(userId: string): Promise<Member> {
|
||||||
|
|
Loading…
Add table
Reference in a new issue