add afk feature

This commit is contained in:
Lee
2024-06-27 14:29:48 +01:00
parent 0fc5e6514a
commit 576f7b156d
9 changed files with 290 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import lombok.NonNull;
import lombok.extern.log4j.Log4j2;
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
@ -52,6 +53,9 @@ public class EventService extends ListenerAdapter {
@Override
public void onGuildMemberJoin(@NotNull GuildMemberJoinEvent event) {
if (event.getUser().isBot()) {
return;
}
BatGuild guild = guildService.getGuild(event.getGuild().getId());
BatUser user = userService.getUser(event.getUser().getId());
@ -62,6 +66,9 @@ public class EventService extends ListenerAdapter {
@Override
public void onGuildMemberRemove(@NonNull GuildMemberRemoveEvent event) {
if (event.getUser().isBot()) {
return;
}
BatGuild guild = guildService.getGuild(event.getGuild().getId());
BatUser user = userService.getUser(event.getUser().getId());
@ -69,4 +76,17 @@ public class EventService extends ListenerAdapter {
listener.onGuildMemberLeave(guild, user, event);
}
}
@Override
public void onMessageReceived(MessageReceivedEvent event) {
if (event.getAuthor().isBot()) {
return;
}
BatGuild guild = guildService.getGuild(event.getGuild().getId());
BatUser user = userService.getUser(event.getAuthor().getId());
for (EventListener listener : LISTENERS) {
listener.onGuildMessageReceive(guild, user, event);
}
}
}