forked from Fascinated/Bat
add afk feature
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user