Skip to content

Commit

Permalink
⚡ Changed member boost event
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsTheSky committed May 1, 2024
1 parent 5a4565f commit df18f71
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ group = 'info.itsthesky'
// Semantic Versioning
def major = '4'
def minor = '15'
def patch = '1'
def patch = '2'

def channel = ''
def channelVersion = ''
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/info/itsthesky/disky/core/SkriptUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,11 @@ public static void error(Node node, String message) {
Skript.error(message);
ParserInstance.get().setNode(previous);
}

public static Date convertDateTime(@Nullable OffsetDateTime dateTime) {
if (dateTime == null)
return null;

return new Date(dateTime.toInstant().toEpochMilli());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package info.itsthesky.disky.elements.events.member;

import ch.njol.skript.util.Date;
import info.itsthesky.disky.api.events.DiSkyEvent;
import info.itsthesky.disky.api.events.SimpleDiSkyEvent;
import info.itsthesky.disky.core.SkriptUtils;
Expand All @@ -13,21 +14,19 @@
public class MemberBoostEvent extends DiSkyEvent<GuildMemberUpdateBoostTimeEvent> {

static {
register("Member Boost Event", MemberBoostEvent.class, BukkitMemberBoostEvent.class,
"[discord] [guild] member boost (change|update)")
.description("Fired when a member starts or stops boosting a guild can be used to get the old/new boosting time and the guild.")
.examples("member boost change:");
register("Member Boost Time Update Event", MemberBoostEvent.class, BukkitMemberBoostEvent.class,
"[discord] [guild] member boost time (change|update)");

SkriptUtils.registerBotValue(MemberBoostEvent.BukkitMemberBoostEvent.class);

SkriptUtils.registerValue(MemberBoostEvent.BukkitMemberBoostEvent.class, OffsetDateTime.class,
event -> event.getJDAEvent().getOldValue(), -1);
SkriptUtils.registerValue(MemberBoostEvent.BukkitMemberBoostEvent.class, Date.class,
event -> SkriptUtils.convertDateTime(event.getJDAEvent().getOldValue()), -1);

SkriptUtils.registerValue(MemberBoostEvent.BukkitMemberBoostEvent.class, OffsetDateTime.class,
event -> event.getJDAEvent().getNewValue(), 0);
SkriptUtils.registerValue(MemberBoostEvent.BukkitMemberBoostEvent.class, Date.class,
event -> SkriptUtils.convertDateTime(event.getJDAEvent().getNewValue()), 0);

SkriptUtils.registerValue(MemberBoostEvent.BukkitMemberBoostEvent.class, OffsetDateTime.class,
event -> event.getJDAEvent().getNewValue(), 1);
SkriptUtils.registerValue(MemberBoostEvent.BukkitMemberBoostEvent.class, Date.class,
event -> SkriptUtils.convertDateTime(event.getJDAEvent().getNewValue()), 1);

SkriptUtils.registerValue(MemberBoostEvent.BukkitMemberBoostEvent.class, Guild.class,
event -> event.getJDAEvent().getGuild());
Expand Down

0 comments on commit df18f71

Please sign in to comment.