add valid guild and user id check
All checks were successful
Deploy to Dokku / docker (ubuntu-latest) (push) Successful in 38s

This commit is contained in:
Lee 2024-07-01 01:41:40 +01:00
parent b1785ce373
commit a001f2dd4c
2 changed files with 8 additions and 0 deletions

View File

@ -74,6 +74,10 @@ public class GuildService extends ListenerAdapter implements EventListener {
if (guilds.containsKey(id)) {
return guilds.get(id);
}
if (DiscordService.JDA.getGuildById(id) == null) {
log.warn("Attempted to get guild with ID \"{}\" but it does not exist", id);
return null;
}
// Guild is not cached
Document document = MongoService.INSTANCE.getGuildsCollection().find(Filters.eq("_id", id)).first();
if (document != null) {

View File

@ -54,6 +54,10 @@ public class UserService implements EventListener {
if (users.containsKey(id)) {
return users.get(id);
}
if (DiscordService.JDA.getUserById(id) == null) {
log.warn("Attempted to get user with ID \"{}\" but it does not exist", id);
return null;
}
// User is not cached
Document document = MongoService.INSTANCE.getUsersCollection().find(Filters.eq("_id", id)).first();
if (document != null) {