-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Added is member timeout property condition
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/main/java/info/itsthesky/disky/elements/conditions/IsTimeout.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package info.itsthesky.disky.elements.conditions; | ||
|
||
import ch.njol.skript.config.Node; | ||
import ch.njol.skript.lang.Expression; | ||
import ch.njol.skript.lang.SkriptParser; | ||
import ch.njol.util.Kleenean; | ||
import info.itsthesky.disky.api.ReflectionUtils; | ||
import info.itsthesky.disky.api.skript.PropertyCondition; | ||
import info.itsthesky.disky.elements.sections.handler.DiSkyRuntimeHandler; | ||
import net.dv8tion.jda.api.entities.Member; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class IsTimeout extends PropertyCondition<Member> { | ||
|
||
static { | ||
register( | ||
IsTimeout.class, | ||
PropertyType.BE, | ||
"[discord] [member] timeout[ed]", | ||
"member" | ||
); | ||
} | ||
|
||
private Node node; | ||
|
||
@Override | ||
public boolean init(Expression<?>[] exprs, int matchedPattern, @NotNull Kleenean isDelayed, SkriptParser.@NotNull ParseResult parseResult) { | ||
node = getParser().getNode(); | ||
return super.init(exprs, matchedPattern, isDelayed, parseResult); | ||
} | ||
|
||
@Override | ||
public boolean check(Member member) { | ||
if (member == null) | ||
{ | ||
DiSkyRuntimeHandler.exprNotSet(node, ReflectionUtils.getFieldValueViaInstance(this, "expr")); | ||
return false; | ||
} | ||
|
||
return member.isTimedOut(); | ||
} | ||
|
||
@Override | ||
protected String getPropertyName() { | ||
return "timeout"; | ||
} | ||
|
||
} |