diff --git a/src/main/java/info/itsthesky/disky/elements/events/member/MemberTimeoutEvent.java b/src/main/java/info/itsthesky/disky/elements/events/member/MemberTimeoutEvent.java index dcb4731..e49b937 100644 --- a/src/main/java/info/itsthesky/disky/elements/events/member/MemberTimeoutEvent.java +++ b/src/main/java/info/itsthesky/disky/elements/events/member/MemberTimeoutEvent.java @@ -7,11 +7,20 @@ import info.itsthesky.disky.api.skript.SimpleGetterExpression; import info.itsthesky.disky.api.skript.reflects.ReflectEventExpressionFactory; import info.itsthesky.disky.core.SkriptUtils; +import net.dv8tion.jda.api.audit.ActionType; +import net.dv8tion.jda.api.audit.AuditLogChange; +import net.dv8tion.jda.api.audit.AuditLogKey; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.User; +import net.dv8tion.jda.api.events.guild.GuildAuditLogEntryCreateEvent; import net.dv8tion.jda.api.events.guild.member.update.GuildMemberUpdateTimeOutEvent; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; +import java.util.function.Predicate; +import java.util.stream.Collectors; import static info.itsthesky.disky.core.SkriptUtils.convertDateTime; @@ -21,10 +30,7 @@ public class MemberTimeoutEvent extends DiSkyEvent e.getJDAEvent().getGuild()); SkriptUtils.registerValue(BukkitMemberTimeoutEvent.class, Guild.class, event -> event.getJDAEvent().getGuild()); @@ -43,6 +49,19 @@ public class MemberTimeoutEvent extends DiSkyEvent convertDateTime(event.getJDAEvent().getNewTimeOutEnd())); + + SkriptUtils.registerRestValue("author", BukkitMemberTimeoutEvent.class, + event -> event.getLogEvent().getGuild().retrieveMemberById(event.getLogEvent().getEntry().getUserIdLong())); + } + + @Override + public @Nullable ActionType getLogType() { + return ActionType.MEMBER_UPDATE; + } + + @Override + protected Predicate logChecker() { + return event -> event.getEntry().getChangeByKey(AuditLogKey.MEMBER_TIME_OUT) != null; } public static class BukkitMemberTimeoutEvent extends SimpleDiSkyEvent {