From 6d57cbc4a16966ada2a5950d7458f62d5dbeb119 Mon Sep 17 00:00:00 2001 From: easrng Date: Mon, 14 Feb 2022 13:47:05 -0500 Subject: [PATCH] add downloader script --- .gitignore | 1 + scripts/get_emojis.sh | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100755 scripts/get_emojis.sh diff --git a/.gitignore b/.gitignore index ea8c4bf..4f5b1e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +/frontend/emojis/* diff --git a/scripts/get_emojis.sh b/scripts/get_emojis.sh new file mode 100755 index 0000000..c68e332 --- /dev/null +++ b/scripts/get_emojis.sh @@ -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