🚑 Load user of guild on load + fetch on api call for mutuals guilds

This commit is contained in:
SebClem 2022-06-15 22:44:26 +02:00
parent 606d223361
commit fdb118fb53
Signed by: sebclem
GPG Key ID: 5A4308F6A359EA50
2 changed files with 5 additions and 1 deletions

View File

@ -17,7 +17,7 @@ import java.util.List;
@Service
public class GuildService {
public List<Guild> getMutualGuilds(UserEntity user) {
User discordUser = CacheTools.getJdaUser(user);
User discordUser = MainBot.jda.retrieveUserById(user.getDiscordId()).complete();
List<net.dv8tion.jda.api.entities.Guild> mutualGuilds = discordUser.getMutualGuilds();
List<Guild> guildList = new ArrayList<>();

View File

@ -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;
}
}
}