add downloader script

main
easrng 2022-02-14 13:47:05 -05:00
parent 0ce6b32a12
commit 6d57cbc4a1
2 changed files with 24 additions and 0 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/target /target
/frontend/emojis/*

23
scripts/get_emojis.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
set -eu
# Get guild ID
if [ ! "$1" ];then
echo "You need to provide a Discord Guild ID."
exit 1
else
guild="$1"
fi
# Get emoji folder
emojiFolder="$(readlink -f "$(dirname $0)/../frontend/emojis/")"
# Get Discord token
printf "Token: " 1>&2
trap 'stty echo' INT EXIT
stty -echo
read token
printf "\n" 1>&2
stty echo
curl "https://discord.com/api/v9/guilds/${guild}/emojis" -H "Authorization: $token" | jq --raw-output 'map("curl '"'"'https://cdn.discordapp.com/emojis/" + .id + ".png?size=48&quality=lossless'"'"' -o '"'${emojiFolder}/"'" + .name + ".png'"'"'") | join("\n")' | sh