Skip to content

Commit

Permalink
add puppet-mode and add checks for non-successful uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
Mstrodl committed Dec 18, 2021
1 parent 8b4f61e commit eb4ae2e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
11 changes: 6 additions & 5 deletions elcord.el
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,19 @@ See <https://discordapp.com/developers/applications/me>."
(ocaml-mode . "ocaml-mode_icon")
(org-mode . "org-mode_icon")
(pascal-mode . "pascal-mode_icon")
(php-mode . "php-mode_icon")
(puml-mode . "puml-mode_icon")
(puppet-mode . "puppet-mode_icon")
(python-mode . "python-mode_icon")
(racket-mode . "racket-mode_icon")
(ruby-mode . "ruby-mode_icon")
(rust-mode . "rust-mode_icon")
(rustic-mode . "rust-mode_icon")
(zig-mode . "zig-mode_icon")
("^slime-.*" . "lisp-mode_icon")
("^sly-.*$" . "lisp-mode_icon")
(terraform-mode . "terraform-mode_icon")
(typescript-mode . "typescript-mode_icon")
(php-mode . "php-mode_icon")
(python-mode . "python-mode_icon"))
(zig-mode . "zig-mode_icon")
("^slime-.*" . "lisp-mode_icon")
("^sly-.*$" . "lisp-mode_icon"))
"Mapping alist of major modes to icon names to have elcord use.
Note, these icon names must be available as 'small_image' in Discord."
:type '(alist :key-type (choice (symbol :tag "Mode name")
Expand Down
Binary file added icons/puppet-mode_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 13 additions & 8 deletions icons/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,24 @@ NAMES=$(curl https://discord.com/api/v9/oauth2/applications/388338871475240965/a

echo $NAMES

echo "$NAMES" | jq
echo "$NAMES" | jq
for f in *.png; do
NAME="$(basename "$f" .png)"
# Slow, because we call jq each time... We should fix that.
if [[ $(echo "$NAMES" | jq ". | index(\"${NAME}\")") == "null" ]]; then
echo "Publishing $f..."
DATA="data:image/png;base64,$(base64 -w 0 $f)"
echo "{\"name\": \"${NAME}\",\"type\":1,\"image\":\"${DATA}\"}" |
curl https://discord.com/api/v9/oauth2/applications/388338871475240965/assets \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: $DISCORD_TOKEN" \
--data-binary @- || exit $?
OUT=$(echo "{\"name\": \"${NAME}\",\"type\":1,\"image\":\"${DATA}\"}" |\
curl https://discord.com/api/v9/oauth2/applications/388338871475240965/assets \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: $DISCORD_TOKEN" \
--data-binary @-)
if ! echo $OUT | jq -re .id; then
echo "Failed uploading ${NAME}: ${OUT}"
exit 1
else
echo "Uploaded ${NAME} as $(echo $OUT | jq -re .id)!"
fi
fi
done

0 comments on commit eb4ae2e

Please sign in to comment.