fix: Check bot entity exists before getting invites

This commit is contained in:
FoxxMD
2022-09-16 14:29:34 -04:00
parent 81213686ce
commit 07ecc505ff

View File

@@ -1337,11 +1337,19 @@ class Bot implements BotInstanceFunctions {
}
getSubredditInvites(): SubredditInviteDataPersisted[] {
return this.botEntity.getSubredditInvites().map(x => x.toSubredditInviteData());
if(this.botEntity !== undefined) {
return this.botEntity.getSubredditInvites().map(x => x.toSubredditInviteData());
}
this.logger.warn('No bot entity found');
return [];
}
getInvite(id: string): SubredditInvite | undefined {
return this.botEntity.getSubredditInvites().find(x => x.id === id);
if(this.botEntity !== undefined) {
return this.botEntity.getSubredditInvites().find(x => x.id === id);
}
this.logger.warn('No bot entity found');
return undefined;
}
getOnboardingReadiness(invite: SubredditInvite): SubredditOnboardingReadiness {