aboutsummaryrefslogtreecommitdiff
path: root/example/simple.sh
blob: a756ee4447b59d1d9023f77751a9b53f433a93c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/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)"

	if [[ "$(echo "$1" | jq -r .author.bot)" = "true" ]]; then
		return
	fi
	atrocity_debug "Found message with content $content"

	case "$content" in
	\!ping)
		atrocity_rest POST /channels/"$channel"/messages '{"content": "Pong", "embeds": [{"title": "Pong", "description": "You have been ponginated"}]}'
		;;
	esac
}

atrocity_connect

atrocity_loop