diff --git a/src/main/java/org/camelia/studio/gachamelia/Gachamelia.java b/src/main/java/org/camelia/studio/gachamelia/Gachamelia.java index e64628f..6770905 100644 --- a/src/main/java/org/camelia/studio/gachamelia/Gachamelia.java +++ b/src/main/java/org/camelia/studio/gachamelia/Gachamelia.java @@ -9,8 +9,6 @@ import org.camelia.studio.gachamelia.utils.Configuration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.List; - public class Gachamelia { private static JDA jda; private static final Logger logger = LoggerFactory.getLogger(Gachamelia.class); @@ -32,6 +30,10 @@ public class Gachamelia { HibernateConfig.shutdown(); jda.shutdown(); })); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + logger.error("Le thread a été interrompu : {}", e.getMessage()); + System.exit(1); } catch (Exception e) { logger.error("Une erreur est survenue lors de l'exécution du bot : {}", e.getMessage()); System.exit(1); diff --git a/src/main/java/org/camelia/studio/gachamelia/listeners/GuildMemberJoinListener.java b/src/main/java/org/camelia/studio/gachamelia/listeners/GuildMemberJoinListener.java index da3f4d7..993d29c 100644 --- a/src/main/java/org/camelia/studio/gachamelia/listeners/GuildMemberJoinListener.java +++ b/src/main/java/org/camelia/studio/gachamelia/listeners/GuildMemberJoinListener.java @@ -11,13 +11,13 @@ import org.camelia.studio.gachamelia.models.WelcomeMessage; import org.camelia.studio.gachamelia.services.RankService; import org.camelia.studio.gachamelia.services.UserService; import org.camelia.studio.gachamelia.utils.Configuration; - import java.awt.*; +import javax.annotation.Nonnull; public class GuildMemberJoinListener extends ListenerAdapter { @Override - public void onGuildMemberJoin(GuildMemberJoinEvent event) { + public void onGuildMemberJoin(@Nonnull GuildMemberJoinEvent event) { Member member = event.getMember(); User user = UserService.getInstance().getOrCreateUser(member.getId()); diff --git a/src/main/java/org/camelia/studio/gachamelia/listeners/GuildMemberLeaveListener.java b/src/main/java/org/camelia/studio/gachamelia/listeners/GuildMemberLeaveListener.java index 3146e6e..47ec393 100644 --- a/src/main/java/org/camelia/studio/gachamelia/listeners/GuildMemberLeaveListener.java +++ b/src/main/java/org/camelia/studio/gachamelia/listeners/GuildMemberLeaveListener.java @@ -10,15 +10,15 @@ import org.camelia.studio.gachamelia.models.User; import org.camelia.studio.gachamelia.services.RankService; import org.camelia.studio.gachamelia.services.UserService; import org.camelia.studio.gachamelia.utils.Configuration; - import java.awt.*; import java.time.Instant; +import javax.annotation.Nonnull; public class GuildMemberLeaveListener extends ListenerAdapter { @Override - public void onGuildMemberRemove(GuildMemberRemoveEvent event) { + public void onGuildMemberRemove(@Nonnull GuildMemberRemoveEvent event) { net.dv8tion.jda.api.entities.User discordUser = event.getUser(); User user = UserService.getInstance().getOrCreateUser(discordUser.getId()); @@ -37,7 +37,7 @@ public class GuildMemberLeaveListener extends ListenerAdapter { StringBuilder description = new StringBuilder(); - description.append(byeMessage.getMessage().replaceAll("%username%", "**" + discordUser.getEffectiveName() + "**")); + description.append(byeMessage.getMessage().replace("%username%", "**" + discordUser.getEffectiveName() + "**")); EmbedBuilder embedBuilder = new EmbedBuilder() .setTitle(user.getRank().getByeTitle() != null ? user.getRank().getByeTitle() : "Au revoir, %s !".formatted(discordUser.getEffectiveName())) diff --git a/src/main/java/org/camelia/studio/gachamelia/listeners/ReadyListener.java b/src/main/java/org/camelia/studio/gachamelia/listeners/ReadyListener.java index 87adaae..77863bf 100644 --- a/src/main/java/org/camelia/studio/gachamelia/listeners/ReadyListener.java +++ b/src/main/java/org/camelia/studio/gachamelia/listeners/ReadyListener.java @@ -5,6 +5,7 @@ import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.events.session.ReadyEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; +import javax.annotation.Nonnull; import org.camelia.studio.gachamelia.models.User; import org.camelia.studio.gachamelia.repossitories.RankRepository; import org.camelia.studio.gachamelia.services.RankService; @@ -18,7 +19,7 @@ public class ReadyListener extends ListenerAdapter { @Override - public void onReady(ReadyEvent event) { + public void onReady(@Nonnull ReadyEvent event) { logger.info("Connecté en tant que {}", event.getJDA().getSelfUser().getAsTag()); initDatabase(event.getJDA()); } diff --git a/src/main/java/org/camelia/studio/gachamelia/listeners/SlashCommandListener.java b/src/main/java/org/camelia/studio/gachamelia/listeners/SlashCommandListener.java index 79fe364..620a22d 100644 --- a/src/main/java/org/camelia/studio/gachamelia/listeners/SlashCommandListener.java +++ b/src/main/java/org/camelia/studio/gachamelia/listeners/SlashCommandListener.java @@ -2,8 +2,8 @@ package org.camelia.studio.gachamelia.listeners; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; +import javax.annotation.Nonnull; import org.camelia.studio.gachamelia.managers.CommandManager; -import org.jetbrains.annotations.NotNull; public class SlashCommandListener extends ListenerAdapter { private final CommandManager commandManager; @@ -15,7 +15,7 @@ public class SlashCommandListener extends ListenerAdapter { @Override - public void onSlashCommandInteraction(@NotNull SlashCommandInteractionEvent event) { + public void onSlashCommandInteraction(@Nonnull SlashCommandInteractionEvent event) { event.deferReply().setEphemeral(true).queue(); commandManager.handleCommand(event.getName(), event); }