Merge branch 'develop'
This commit is contained in:
commit
70015b0a70
@ -50,7 +50,7 @@ dependencies {
|
||||
|
||||
|
||||
|
||||
compile("com.sedmelluq:lavaplayer:1.3.54")
|
||||
compile("com.sedmelluq:lavaplayer:1.3.61")
|
||||
// compile 'net.dv8tion:JDA:4.0.0_46'
|
||||
compile 'net.dv8tion:JDA:4.2.0_214'
|
||||
compile group: 'org.json', name: 'json', version: '20160810'
|
||||
|
@ -1,15 +1,30 @@
|
||||
package net.Broken.Tools;
|
||||
|
||||
import net.Broken.DB.Entity.UserEntity;
|
||||
import net.Broken.MainBot;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CacheTools {
|
||||
public static void loadAllGuildMembers(){
|
||||
private static Logger logger = LogManager.getLogger();
|
||||
|
||||
public static void loadAllGuildMembers() {
|
||||
List<Guild> guilds = MainBot.jda.getGuilds();
|
||||
for(Guild guild : guilds){
|
||||
for (Guild guild : guilds) {
|
||||
guild.loadMembers().get();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import net.Broken.DB.Repository.UserRepository;
|
||||
import net.Broken.DB.Repository.UserStatsRepository;
|
||||
import net.Broken.MainBot;
|
||||
import net.Broken.SpringContext;
|
||||
import net.Broken.Tools.CacheTools;
|
||||
import net.Broken.Tools.EmbedMessageUtils;
|
||||
import net.Broken.Tools.UserManager.Exceptions.UnknownTokenException;
|
||||
import net.Broken.Tools.UserManager.UserUtils;
|
||||
@ -58,7 +59,7 @@ public class UserStatsUtils {
|
||||
}
|
||||
|
||||
public List<UserStats> getUserStats(UserEntity userEntity) {
|
||||
User jdaUser = MainBot.jda.getUserById(userEntity.getJdaId());
|
||||
User jdaUser = CacheTools.getJdaUser(userEntity);
|
||||
//TODO clean database for deleted users
|
||||
|
||||
if (jdaUser == null){
|
||||
|
Loading…
Reference in New Issue
Block a user