forked from Fascinated/Bat
impl member timeout logging
This commit is contained in:
parent
8b7340715c
commit
120afee73b
@ -17,6 +17,7 @@ import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent;
|
|||||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleAddEvent;
|
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleAddEvent;
|
||||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleRemoveEvent;
|
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleRemoveEvent;
|
||||||
import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateNicknameEvent;
|
import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateNicknameEvent;
|
||||||
|
import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateTimeOutEvent;
|
||||||
import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent;
|
import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent;
|
||||||
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
|
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
|
||||||
import net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent;
|
import net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent;
|
||||||
@ -190,6 +191,15 @@ public interface EventListener {
|
|||||||
default void onGuildMemberUnban(@NonNull BatGuild guild, @NonNull BatUser user, @NonNull GuildUnbanEvent event) {
|
default void onGuildMemberUnban(@NonNull BatGuild guild, @NonNull BatUser user, @NonNull GuildUnbanEvent event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a user gets timed out in a guild (gets muted)
|
||||||
|
*
|
||||||
|
* @param guild the guild that the user timed out in
|
||||||
|
* @param user the user that timed out
|
||||||
|
*/
|
||||||
|
default void onGuildMemberTimeout(@NonNull BatGuild guild, @NonNull BatUser user, @NonNull GuildMemberUpdateTimeOutEvent event) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when Spring is shutting down
|
* Called when Spring is shutting down
|
||||||
*/
|
*/
|
||||||
|
@ -26,6 +26,7 @@ public enum LogType {
|
|||||||
MEMBER_ROLE_UPDATE(LogCategory.MEMBER, "Member Role Update"),
|
MEMBER_ROLE_UPDATE(LogCategory.MEMBER, "Member Role Update"),
|
||||||
MEMBER_BAN(LogCategory.MEMBER, "Member Ban"),
|
MEMBER_BAN(LogCategory.MEMBER, "Member Ban"),
|
||||||
MEMBER_UNBAN(LogCategory.MEMBER, "Member Unban"),
|
MEMBER_UNBAN(LogCategory.MEMBER, "Member Unban"),
|
||||||
|
MEMBER_TIMEOUT(LogCategory.MEMBER, "Member Timeout"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Channel Events
|
* Channel Events
|
||||||
|
@ -16,10 +16,12 @@ import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent;
|
|||||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleAddEvent;
|
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleAddEvent;
|
||||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleRemoveEvent;
|
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleRemoveEvent;
|
||||||
import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateNicknameEvent;
|
import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateNicknameEvent;
|
||||||
|
import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateTimeOutEvent;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,8 +118,6 @@ public class MemberListener implements EventListener {
|
|||||||
logFeature.sendLog(guild, LogType.MEMBER_BAN, EmbedUtils.errorEmbed()
|
logFeature.sendLog(guild, LogType.MEMBER_BAN, EmbedUtils.errorEmbed()
|
||||||
.setDescription(new EmbedDescriptionBuilder("Member Banned")
|
.setDescription(new EmbedDescriptionBuilder("Member Banned")
|
||||||
.appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true)
|
.appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true)
|
||||||
.appendLine("Username: %s".formatted(user.getDiscordUser().getName()), true)
|
|
||||||
.appendLine("Snowflake: %s".formatted(user.getId()), true)
|
|
||||||
.build())
|
.build())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
@ -129,8 +129,21 @@ public class MemberListener implements EventListener {
|
|||||||
logFeature.sendLog(guild, LogType.MEMBER_UNBAN, EmbedUtils.successEmbed()
|
logFeature.sendLog(guild, LogType.MEMBER_UNBAN, EmbedUtils.successEmbed()
|
||||||
.setDescription(new EmbedDescriptionBuilder("Member Unbanned")
|
.setDescription(new EmbedDescriptionBuilder("Member Unbanned")
|
||||||
.appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true)
|
.appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true)
|
||||||
.appendLine("Username: %s".formatted(user.getDiscordUser().getName()), true)
|
.build())
|
||||||
.appendLine("Snowflake: %s".formatted(user.getId()), true)
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGuildMemberTimeout(@NonNull BatGuild guild, @NonNull BatUser user, @NonNull GuildMemberUpdateTimeOutEvent event) {
|
||||||
|
OffsetDateTime timeoutEnd = event.getNewTimeOutEnd();
|
||||||
|
if (user.getDiscordUser().isBot() || timeoutEnd == null) return;
|
||||||
|
|
||||||
|
long millis = timeoutEnd.toInstant().toEpochMilli();
|
||||||
|
logFeature.sendLog(guild, LogType.MEMBER_TIMEOUT, EmbedUtils.errorEmbed()
|
||||||
|
.setDescription(new EmbedDescriptionBuilder("Member Timed Out")
|
||||||
|
.appendLine("Member: %s".formatted(user.getDiscordUser().getAsMention()), true)
|
||||||
|
.appendLine("Timeout End: <t:%s>".formatted(millis), true)
|
||||||
|
.appendLine("Relative: <t:%s:R>".formatted(millis), true)
|
||||||
.build())
|
.build())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent;
|
|||||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleAddEvent;
|
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleAddEvent;
|
||||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleRemoveEvent;
|
import net.dv8tion.jda.api.events.guild.member.GuildMemberRoleRemoveEvent;
|
||||||
import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateNicknameEvent;
|
import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateNicknameEvent;
|
||||||
|
import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateTimeOutEvent;
|
||||||
import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent;
|
import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent;
|
||||||
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
|
import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent;
|
||||||
import net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent;
|
import net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent;
|
||||||
@ -250,4 +251,17 @@ public class EventService extends ListenerAdapter {
|
|||||||
listener.onGuildMemberUnban(guild, user, event);
|
listener.onGuildMemberUnban(guild, user, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onGuildMemberUpdateTimeOut(@NotNull GuildMemberUpdateTimeOutEvent event) {
|
||||||
|
if (event.getUser().isBot()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BatGuild guild = guildService.getGuild(event.getGuild().getId());
|
||||||
|
BatUser user = userService.getUser(event.getUser().getId());
|
||||||
|
|
||||||
|
for (EventListener listener : LISTENERS) {
|
||||||
|
listener.onGuildMemberTimeout(guild, user, event);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user