Skip to content

Commit

Permalink
Add create Discord emote using image effect
Browse files Browse the repository at this point in the history
  • Loading branch information
Blueyescat committed Jan 23, 2019
1 parent 423ec90 commit 0855b9a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions elements/Vixio/-Vixio-code.sk
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import:

net.dv8tion.jda.core.EmbedBuilder
net.dv8tion.jda.core.MessageBuilder
net.dv8tion.jda.core.entities.Icon
net.dv8tion.jda.core.entities.User
net.dv8tion.jda.core.exceptions.RateLimitedException

# UploadImage
effect:
patterns:
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%]
Expand Down Expand Up @@ -80,4 +82,27 @@ effect:
set {_varExpr} to raw expression-5
if {_varExpr} is set:
VixioUtil.storeInVar(VixioSkriptUtil.getVariableName({_varExpr}), {_varExpr}, UpdatingMessage.from({_resultingMessage}), event)
continue

# CreateEmote
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%]:
trigger:
if expression-1 isn't instance of BufferedImage:
stop
if expression-2 is set:
set {_format} to expression-2
else:
set {_format} to "png"
set {_name} to expression-3
replace all " " with "_" in {_name}
delay the current effect
set {_bot} to VixioUtil.botFrom(expression-5)
set {_guild} to VixioUtil.bindGuild({_bot}, expression-4)
if {_name}, {_format}, {_bot} or {_guild} is not set:
continue
set {_baos} to new ByteArrayOutputStream()
ImageIO.write(expression-1, {_format}, {_baos})
set {_is} to new ByteArrayInputStream({_baos}.toByteArray())
set {_icon} to Icon.from({_is})
expression-4.getController().createEmote({_name}, {_icon}).queue()
continue
1 change: 1 addition & 0 deletions elements/effects/CreateImage.sk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ effect:
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%]
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%]
parse:
# skript-mirror bug, it sees the patterns as 29 and 17 in parse section only
if matched pattern is 29:
set {_varExpr} to expression-6
else:
Expand Down

0 comments on commit 0855b9a

Please sign in to comment.