From fdb118fb5337a8d18701e51f08c2dee003a33e94 Mon Sep 17 00:00:00 2001 From: SebClem Date: Wed, 15 Jun 2022 22:44:26 +0200 Subject: [PATCH] :ambulance: Load user of guild on load + fetch on api call for mutuals guilds --- src/main/java/net/Broken/Api/Services/GuildService.java | 2 +- src/main/java/net/Broken/BotListener.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/Broken/Api/Services/GuildService.java b/src/main/java/net/Broken/Api/Services/GuildService.java index 71dd64a..3a51d0f 100644 --- a/src/main/java/net/Broken/Api/Services/GuildService.java +++ b/src/main/java/net/Broken/Api/Services/GuildService.java @@ -17,7 +17,7 @@ import java.util.List; @Service public class GuildService { public List getMutualGuilds(UserEntity user) { - User discordUser = CacheTools.getJdaUser(user); + User discordUser = MainBot.jda.retrieveUserById(user.getDiscordId()).complete(); List mutualGuilds = discordUser.getMutualGuilds(); List guildList = new ArrayList<>(); diff --git a/src/main/java/net/Broken/BotListener.java b/src/main/java/net/Broken/BotListener.java index af6b530..589bb48 100644 --- a/src/main/java/net/Broken/BotListener.java +++ b/src/main/java/net/Broken/BotListener.java @@ -193,6 +193,9 @@ public class BotListener extends ListenerAdapter { logger.info("Join new guild! (" + event.getGuild().getName() + " " + event.getGuild().getMembers().size() + " Members)"); super.onGuildJoin(event); getPreference(event.getGuild()); + event.getGuild().loadMembers().onSuccess((members -> { + logger.debug("[" + event.getGuild().getName() + "] Members loaded"); + })); EmbedBuilder eb = new EmbedBuilder().setColor(Color.GREEN) .setTitle("Hello there !") .setDescription("Allow me to introduce myself -- I am a CL4P-TP the discord bot, but my friends call me Claptrap ! Or they would, if any of them were real...\n" + @@ -207,6 +210,7 @@ public class BotListener extends ListenerAdapter { for (TextChannel chan : event.getGuild().getTextChannels()) { if (chan.canTalk()) { chan.sendMessage(message).queue(); + break; } } }