Skip to content

Commit 0855b9a

Browse files
committed
Add create Discord emote using image effect
1 parent 423ec90 commit 0855b9a

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

elements/Vixio/-Vixio-code.sk

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ import:
1313

1414
net.dv8tion.jda.core.EmbedBuilder
1515
net.dv8tion.jda.core.MessageBuilder
16+
net.dv8tion.jda.core.entities.Icon
1617
net.dv8tion.jda.core.entities.User
1718
net.dv8tion.jda.core.exceptions.RateLimitedException
1819

20+
# UploadImage
1921
effect:
2022
patterns:
2123
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%]
@@ -80,4 +82,27 @@ effect:
8082
set {_varExpr} to raw expression-5
8183
if {_varExpr} is set:
8284
VixioUtil.storeInVar(VixioSkriptUtil.getVariableName({_varExpr}), {_varExpr}, UpdatingMessage.from({_resultingMessage}), event)
85+
continue
86+
87+
# CreateEmote
88+
effect create [a[n]] [new] (emote|emoji) (using|from|with) [(image|img)] %object% [with ([(format|file)] type|[file] format) %-string%] (named|with [the] name) %string% [in %guild%] [with %bot/string%]:
89+
trigger:
90+
if expression-1 isn't instance of BufferedImage:
91+
stop
92+
if expression-2 is set:
93+
set {_format} to expression-2
94+
else:
95+
set {_format} to "png"
96+
set {_name} to expression-3
97+
replace all " " with "_" in {_name}
98+
delay the current effect
99+
set {_bot} to VixioUtil.botFrom(expression-5)
100+
set {_guild} to VixioUtil.bindGuild({_bot}, expression-4)
101+
if {_name}, {_format}, {_bot} or {_guild} is not set:
102+
continue
103+
set {_baos} to new ByteArrayOutputStream()
104+
ImageIO.write(expression-1, {_format}, {_baos})
105+
set {_is} to new ByteArrayInputStream({_baos}.toByteArray())
106+
set {_icon} to Icon.from({_is})
107+
expression-4.getController().createEmote({_name}, {_icon}).queue()
83108
continue

elements/effects/CreateImage.sk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ effect:
1313
create [a[n]] [new] image with (width %-number%[( and|,)] [with] height %-number%|1¦height %-number%[( and|,)] [with] width %-number%)[[( and|,)] [with] [b[ack]g[round]] [(paint|gradient)] %-object%] [[and] (store|save) ([[the] result]|it) (in|to) [variable] %-object%]
1414
create [a[n]] [new] image with (width %-number%[( and|,)] [with] height %-number%|1¦height %-number%[( and|,)] [with] width %-number%) [[and] (store|save) ([[the] result]|it) (in|to) [variable] %-object%]
1515
parse:
16+
# skript-mirror bug, it sees the patterns as 29 and 17 in parse section only
1617
if matched pattern is 29:
1718
set {_varExpr} to expression-6
1819
else:

0 commit comments

Comments
 (0)