Skip to content

Commit

Permalink
Add ability to store the message in variable for upload image effect
Browse files Browse the repository at this point in the history
  • Loading branch information
Blueyescat committed Jan 17, 2019
1 parent f0285d6 commit 727ad62
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
27 changes: 23 additions & 4 deletions elements/Vixio/-Vixio-code.sk
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import:
java.io.ByteArrayOutputStream
javax.imageio.ImageIO

ch.njol.skript.lang.Variable

me.iblitzkriegi.vixio.Vixio
me.iblitzkriegi.vixio.util.UpdatingMessage
me.iblitzkriegi.vixio.util.Util as VixioUtil
me.iblitzkriegi.vixio.util.skript.SkriptUtil as VixioSkriptUtil

net.dv8tion.jda.core.EmbedBuilder
net.dv8tion.jda.core.MessageBuilder
Expand All @@ -15,8 +18,18 @@ import:

effect:
patterns:
upload (image|img) %object% [with ([(format|file)] type|[file] format) %-string%] [with (message|embed) %-message/string%] to %user/channel% [with %bot/string%]
upload [the] [last[ly]] [(created|generated|received|taken)] (image|img) [with ([(format|file)] type|[file] format) %-string%] [with (message|embed) %-message/string%] to %user/channel% [with %bot/string%]
upload (image|img) %object% [with ([(format|file)] type|[file] format) %-string%] [with (message|embed) %-message/string%] to %user/channel% [with %bot/string%] [and store (it|the message) in %-objects%]
upload [the] [last[ly]] [(created|generated|received|taken)] (image|img) [with ([(format|file)] type|[file] format) %-string%] [with (message|embed) %-message/string%] to %user/channel% [with %bot/string%] [and store (it|the message) in %-objects%]
parse:
if matched pattern is 1:
set {_varExpr} to expression-6
else:
set {_varExpr} to expression-5
if {_varExpr} is set:
if {_varExpr} isn't instance of Variable:
imagesk parse error "'%{_varExpr}%' is not a variable."
stop
continue
trigger:
if matched pattern is 1:
set {_image} to expression-1
Expand Down Expand Up @@ -57,7 +70,13 @@ effect:
ImageIO.write({_image}, {_format}, {_os})
set {_is} to new ByteArrayInputStream({_os}.toByteArray())
if {_message} is set:
{_bindedChannel}.sendMessage({_message}).addFile({_is}, "image.%{_format}%").queue()
set {_resultingMessage} to {_bindedChannel}.sendMessage({_message}).addFile({_is}, "image.%{_format}%").complete(true)
else:
set {_resultingMessage} to {_bindedChannel}.sendFile({_is}, "image.%{_format}%").complete(true)
if matched pattern is 1:
set {_varExpr} to raw expression-6
else:
{_bindedChannel}.sendFile({_is}, "image.%{_format}%").queue()
set {_varExpr} to raw expression-5
if {_varExpr} is set:
VixioUtil.storeInVar(VixioSkriptUtil.getVariableName({_varExpr}), {_varExpr}, UpdatingMessage.from({_resultingMessage}), event)
continue
2 changes: 1 addition & 1 deletion elements/expressions/LinearGradient.sk
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ expression [a] [new] [(1¦(repeating|repeated)|2¦(reflected|reflecting))] linea
set {_method} to CycleMethod.REPEAT!
else if parse mark is 2 or 8:
set {_method} to CycleMethod.REFLECT!
return new LinearGradientPaint({_x1}, {_y1}, {_x2}, {_y2}, [{_fractions::*}], [{_colors::*}], {_method})
return new LinearGradientPaint({_x1}, {_y1}, {_x2}, {_y2}, [{_fractions::*}], [{_colors::*}], {_method})

0 comments on commit 727ad62

Please sign in to comment.