quick fix
This commit is contained in:
parent
bb08e3b614
commit
352a87a1f3
@ -159,7 +159,12 @@ public class MusicWebAPIController {
|
|||||||
logger.info("Receive command " + data.command + " from " + request.getRemoteAddr() + " USER: " + user.getName() + " GUILD: " + guild.getName());
|
logger.info("Receive command " + data.command + " from " + request.getRemoteAddr() + " USER: " + user.getName() + " GUILD: " + guild.getName());
|
||||||
|
|
||||||
if (ApiCommandLoader.apiCommands.containsKey(data.command)) {
|
if (ApiCommandLoader.apiCommands.containsKey(data.command)) {
|
||||||
UserStatsUtils.getINSTANCE().addApiCount(user, guildId);
|
try {
|
||||||
|
UserStatsUtils.getINSTANCE().addApiCount(user, guildId);
|
||||||
|
|
||||||
|
}catch (IndexOutOfBoundsException e){
|
||||||
|
logger.catching(e);
|
||||||
|
}
|
||||||
return ApiCommandLoader.apiCommands.get(data.command).action(data, MainBot.jda.getUserById(user.getJdaId()), guild);
|
return ApiCommandLoader.apiCommands.get(data.command).action(data, MainBot.jda.getUserById(user.getJdaId()), guild);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -45,6 +45,8 @@ public class UserStatsUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<UserStats> getUserStats(UserEntity userEntity){
|
public List<UserStats> getUserStats(UserEntity userEntity){
|
||||||
|
logger.debug(userEntity.getUserStats());
|
||||||
|
logger.debug(userEntity.getUserStats().size());
|
||||||
if(userEntity.getUserStats() == null || userEntity.getUserStats().size() == 0){
|
if(userEntity.getUserStats() == null || userEntity.getUserStats().size() == 0){
|
||||||
logger.debug("Stats not found for " + userEntity.getName());
|
logger.debug("Stats not found for " + userEntity.getName());
|
||||||
User user = MainBot.jda.getUserById(userEntity.getJdaId());
|
User user = MainBot.jda.getUserById(userEntity.getJdaId());
|
||||||
@ -90,10 +92,12 @@ public class UserStatsUtils {
|
|||||||
userEntity = userEntityList.get(0);
|
userEntity = userEntityList.get(0);
|
||||||
|
|
||||||
List<UserStats> userStatsList = userStatsRepository.findByUserAndGuildId(userEntity, member.getGuild().getId());
|
List<UserStats> userStatsList = userStatsRepository.findByUserAndGuildId(userEntity, member.getGuild().getId());
|
||||||
|
logger.debug("First: " + userStatsList.size());
|
||||||
if(userStatsList.size() == 0){
|
if(userStatsList.size() == 0){
|
||||||
getUserStats(userEntity);
|
getUserStats(userEntity);
|
||||||
userStatsList = userStatsRepository.findByUserAndGuildId(userEntity, member.getGuild().getId());
|
userStatsList = userStatsRepository.findByUserAndGuildId(userEntity, member.getGuild().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
UserStats userStats = userStatsList.get(0);
|
UserStats userStats = userStatsList.get(0);
|
||||||
userStats.setMessageCount(userStats.getMessageCount() + 1);
|
userStats.setMessageCount(userStats.getMessageCount() + 1);
|
||||||
userStatsRepository.save(userStats);
|
userStatsRepository.save(userStats);
|
||||||
@ -105,6 +109,7 @@ public class UserStatsUtils {
|
|||||||
|
|
||||||
|
|
||||||
List<UserStats> userStatsList = userStatsRepository.findByUserAndGuildId(userEntity, guildId);
|
List<UserStats> userStatsList = userStatsRepository.findByUserAndGuildId(userEntity, guildId);
|
||||||
|
logger.debug("First: " + userStatsList.size());
|
||||||
if(userStatsList.size() == 0){
|
if(userStatsList.size() == 0){
|
||||||
getUserStats(userEntity);
|
getUserStats(userEntity);
|
||||||
userStatsList = userStatsRepository.findByUserAndGuildId(userEntity, guildId);
|
userStatsList = userStatsRepository.findByUserAndGuildId(userEntity, guildId);
|
||||||
|
Loading…
Reference in New Issue
Block a user