Skip to content

Commit 727ad62

Browse files
committed
Add ability to store the message in variable for upload image effect
1 parent f0285d6 commit 727ad62

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

elements/Vixio/-Vixio-code.sk

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ import:
44
java.io.ByteArrayOutputStream
55
javax.imageio.ImageIO
66

7+
ch.njol.skript.lang.Variable
8+
79
me.iblitzkriegi.vixio.Vixio
810
me.iblitzkriegi.vixio.util.UpdatingMessage
911
me.iblitzkriegi.vixio.util.Util as VixioUtil
12+
me.iblitzkriegi.vixio.util.skript.SkriptUtil as VixioSkriptUtil
1013

1114
net.dv8tion.jda.core.EmbedBuilder
1215
net.dv8tion.jda.core.MessageBuilder
@@ -15,8 +18,18 @@ import:
1518

1619
effect:
1720
patterns:
18-
upload (image|img) %object% [with ([(format|file)] type|[file] format) %-string%] [with (message|embed) %-message/string%] to %user/channel% [with %bot/string%]
19-
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%]
21+
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%]
22+
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%]
23+
parse:
24+
if matched pattern is 1:
25+
set {_varExpr} to expression-6
26+
else:
27+
set {_varExpr} to expression-5
28+
if {_varExpr} is set:
29+
if {_varExpr} isn't instance of Variable:
30+
imagesk parse error "'%{_varExpr}%' is not a variable."
31+
stop
32+
continue
2033
trigger:
2134
if matched pattern is 1:
2235
set {_image} to expression-1
@@ -57,7 +70,13 @@ effect:
5770
ImageIO.write({_image}, {_format}, {_os})
5871
set {_is} to new ByteArrayInputStream({_os}.toByteArray())
5972
if {_message} is set:
60-
{_bindedChannel}.sendMessage({_message}).addFile({_is}, "image.%{_format}%").queue()
73+
set {_resultingMessage} to {_bindedChannel}.sendMessage({_message}).addFile({_is}, "image.%{_format}%").complete(true)
74+
else:
75+
set {_resultingMessage} to {_bindedChannel}.sendFile({_is}, "image.%{_format}%").complete(true)
76+
if matched pattern is 1:
77+
set {_varExpr} to raw expression-6
6178
else:
62-
{_bindedChannel}.sendFile({_is}, "image.%{_format}%").queue()
79+
set {_varExpr} to raw expression-5
80+
if {_varExpr} is set:
81+
VixioUtil.storeInVar(VixioSkriptUtil.getVariableName({_varExpr}), {_varExpr}, UpdatingMessage.from({_resultingMessage}), event)
6382
continue

elements/expressions/LinearGradient.sk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ expression [a] [new] [(1¦(repeating|repeated)|2¦(reflected|reflecting))] linea
2929
set {_method} to CycleMethod.REPEAT!
3030
else if parse mark is 2 or 8:
3131
set {_method} to CycleMethod.REFLECT!
32-
return new LinearGradientPaint({_x1}, {_y1}, {_x2}, {_y2}, [{_fractions::*}], [{_colors::*}], {_method})
32+
return new LinearGradientPaint({_x1}, {_y1}, {_x2}, {_y2}, [{_fractions::*}], [{_colors::*}], {_method})

0 commit comments

Comments
 (0)