diff options
Diffstat (limited to 'example')
-rw-r--r-- | example/.gitignore | 1 | ||||
-rw-r--r-- | example/env-example.sh | 3 | ||||
-rwxr-xr-x | example/simple.sh | 24 |
3 files changed, 25 insertions, 3 deletions
diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 0000000..137e678 --- /dev/null +++ b/example/.gitignore @@ -0,0 +1 @@ +env.sh diff --git a/example/env-example.sh b/example/env-example.sh new file mode 100644 index 0000000..be6e59c --- /dev/null +++ b/example/env-example.sh @@ -0,0 +1,3 @@ +# Copy this file to env.sh and place your configuration in here + +export ATROCITY_TOKEN="MzEy.............................................................." diff --git a/example/simple.sh b/example/simple.sh index c90c451..a756ee4 100755 --- a/example/simple.sh +++ b/example/simple.sh @@ -1,12 +1,30 @@ #!/usr/bin/env bash +source "$(dirname -- "$0")"/env.sh source "$(dirname -- "$0")"/../load.sh atrocity_debug Simple example loaded +atrocity_on_GUILD_CREATE() { + atrocity_debug "Guild: $(echo "$1" | jq -r .name)" +} +atrocity_on_unknown() { + atrocity_debug "Unknown event $1" +} +atrocity_on_MESSAGE_CREATE() { + local content + local channel + content="$(echo "$1" | jq -r .content)" + channel="$(echo "$1" | jq -r .channel_id)" -export ATROCITY_TOKEN="MzEyMjU2ODcxMTc0MTExMjMz.GPe_v6.4Acwm7tje3sMEvUu05NPyQrZalh8knTIHPgLmk" + if [[ "$(echo "$1" | jq -r .author.bot)" = "true" ]]; then + return + fi + atrocity_debug "Found message with content $content" -atrocity_dispatch() { - echo "Dispatching $1" + case "$content" in + \!ping) + atrocity_rest POST /channels/"$channel"/messages '{"content": "Pong", "embeds": [{"title": "Pong", "description": "You have been ponginated"}]}' + ;; + esac } atrocity_connect |