-
-
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 a better null check for emojis in react section * ⚡ Added a null check for 'has role' condition * ✨ Added way to reply to deferred & waited interactions * ⚡ DiSky v4.12.0 * 🐛 Fixed event-channel (see #138) * ⚡ Enhanced bot login error system * ⚡ Added way to use options in entries * ⚡ Moved scopes/structs loading after Skript verifications * ⚡ Removed debug message from BaseScope.java * ⚡ Added a better error try/catch system for the nickname effect * ✨ Added JSON serialization for embeds * 🔥 Discriminator are no longer defaulted in toString methods * ⚡ Bumped to JDA v5-beta13 🚀 DiSky v4.12.1
- Loading branch information
Showing
7 changed files
with
147 additions
and
7 deletions.
There are no files selected for viewing
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
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
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
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
58 changes: 58 additions & 0 deletions
58
src/main/java/info/itsthesky/disky/elements/properties/embeds/EmbedFromJSON.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,58 @@ | ||
package info.itsthesky.disky.elements.properties.embeds; | ||
|
||
import ch.njol.skript.Skript; | ||
import ch.njol.skript.lang.Expression; | ||
import ch.njol.skript.lang.ExpressionType; | ||
import ch.njol.skript.lang.SkriptParser; | ||
import ch.njol.skript.lang.util.SimpleExpression; | ||
import ch.njol.util.Kleenean; | ||
import info.itsthesky.disky.api.skript.EasyElement; | ||
import info.itsthesky.disky.core.Utils; | ||
import net.dv8tion.jda.api.EmbedBuilder; | ||
import org.bukkit.event.Event; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class EmbedFromJSON extends SimpleExpression<EmbedBuilder> { | ||
|
||
static { | ||
Skript.registerExpression( | ||
EmbedFromJSON.class, | ||
EmbedBuilder.class, | ||
ExpressionType.COMBINED, | ||
"[the] embed (from|of) [json] %string%" | ||
); | ||
} | ||
|
||
private Expression<String> exprJSON; | ||
|
||
@Override | ||
public boolean init(Expression<?>[] exprs, int matchedPattern, @NotNull Kleenean isDelayed, SkriptParser.@NotNull ParseResult parseResult) { | ||
exprJSON = (Expression<String>) exprs[0]; | ||
return true; | ||
} | ||
|
||
@Override | ||
protected EmbedBuilder @NotNull [] get(@NotNull Event e) { | ||
final String json = EasyElement.parseSingle(exprJSON, e); | ||
if (json == null) | ||
return new EmbedBuilder[0]; | ||
|
||
return new EmbedBuilder[] {Utils.convertJSONToEmbed(json)}; | ||
} | ||
|
||
@Override | ||
public boolean isSingle() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public @NotNull Class<? extends EmbedBuilder> getReturnType() { | ||
return EmbedBuilder.class; | ||
} | ||
|
||
@Override | ||
public @NotNull String toString(@Nullable Event e, boolean debug) { | ||
return "embed from json " + exprJSON.toString(e, debug); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/info/itsthesky/disky/elements/properties/embeds/EmbedToJSON.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,58 @@ | ||
package info.itsthesky.disky.elements.properties.embeds; | ||
|
||
import ch.njol.skript.Skript; | ||
import ch.njol.skript.lang.Expression; | ||
import ch.njol.skript.lang.ExpressionType; | ||
import ch.njol.skript.lang.SkriptParser; | ||
import ch.njol.skript.lang.util.SimpleExpression; | ||
import ch.njol.util.Kleenean; | ||
import info.itsthesky.disky.api.skript.EasyElement; | ||
import info.itsthesky.disky.core.Utils; | ||
import net.dv8tion.jda.api.EmbedBuilder; | ||
import org.bukkit.event.Event; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class EmbedToJSON extends SimpleExpression<String> { | ||
|
||
static { | ||
Skript.registerExpression( | ||
EmbedToJSON.class, | ||
String.class, | ||
ExpressionType.COMBINED, | ||
"[the] embed %embedbuilder% (to|as) json" | ||
); | ||
} | ||
|
||
private Expression<EmbedBuilder> exprJSON; | ||
|
||
@Override | ||
public boolean init(Expression<?>[] exprs, int matchedPattern, @NotNull Kleenean isDelayed, SkriptParser.@NotNull ParseResult parseResult) { | ||
exprJSON = (Expression<EmbedBuilder>) exprs[0]; | ||
return true; | ||
} | ||
|
||
@Override | ||
protected String @NotNull [] get(@NotNull Event e) { | ||
final EmbedBuilder embedBuilder = EasyElement.parseSingle(exprJSON, e); | ||
if (embedBuilder == null) | ||
return new String[0]; | ||
|
||
return new String[] {Utils.convertEmbedToJSON(embedBuilder)}; | ||
} | ||
|
||
@Override | ||
public boolean isSingle() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public @NotNull Class<? extends String> getReturnType() { | ||
return String.class; | ||
} | ||
|
||
@Override | ||
public @NotNull String toString(@Nullable Event e, boolean debug) { | ||
return "embed from json " + exprJSON.toString(e, debug); | ||
} | ||
} |
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