2020-11-18 19:25:07 +01:00
|
|
|
package net.Broken.Tools;
|
|
|
|
|
2020-11-23 14:29:44 +01:00
|
|
|
import net.Broken.DB.Entity.UserEntity;
|
2020-11-18 19:25:07 +01:00
|
|
|
import net.Broken.MainBot;
|
|
|
|
import net.dv8tion.jda.api.entities.Guild;
|
2020-11-23 14:29:44 +01:00
|
|
|
import net.dv8tion.jda.api.entities.User;
|
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
2020-11-18 19:25:07 +01:00
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class CacheTools {
|
2020-11-23 14:29:44 +01:00
|
|
|
private static Logger logger = LogManager.getLogger();
|
|
|
|
|
|
|
|
public static void loadAllGuildMembers() {
|
2020-11-18 19:25:07 +01:00
|
|
|
List<Guild> guilds = MainBot.jda.getGuilds();
|
2020-11-23 14:29:44 +01:00
|
|
|
for (Guild guild : guilds) {
|
2020-11-18 19:25:07 +01:00
|
|
|
guild.loadMembers().get();
|
|
|
|
}
|
|
|
|
}
|
2020-11-23 14:29:44 +01:00
|
|
|
|
|
|
|
public static User getJdaUser(UserEntity userEntity) {
|
|
|
|
User user = MainBot.jda.getUserById(userEntity.getJdaId());
|
|
|
|
if (user == null) {
|
|
|
|
logger.debug("User cache not found for " + userEntity.getName() + ", fetching user.");
|
|
|
|
user = MainBot.jda.retrieveUserById(userEntity.getJdaId()).complete();
|
|
|
|
}
|
|
|
|
return user;
|
|
|
|
}
|
2020-11-18 19:25:07 +01:00
|
|
|
}
|