-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreaction.yag
62 lines (50 loc) · 2.2 KB
/
reaction.yag
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{{/*
PokeNav Grant Badge with Badge emoji reaction
Checks if reaction emoji starts with "bg" and issues grant badge command
Trigger: reaction
Required Roles: Pokenav Badge Moderator role
Limit to channel where messages that you want to add reactions to in order to grant badges
This script assumes that you name all of your boss badges staring with "bg"
If you use different letters/word at the beginning of the emoji name,
go to line 40 and change ^bg to ^whatever
the ^ means "starts with" which is the easiest type of search to do
*/}}
{{/* Set Channel IDs Here */}}
{{/* ID of channel where grant badge command should be sent by YAGPDB */}}
{{ $commandChannelID := 639594333867212816}}
{{/* ID of channel where reactions are added
so that YAGPDB can delete checkEmoji when badge revoked */}}
{{ $channelID := 347028159239290880}}
{{/* Checkmark emoji and YAG userID */}}
{{ $checkEmoji := ":gbCheck:896481862388711484"}}
{{ $YAGid := 204255221017214977 }}
{{/* ------------ DO NOT ALTER CODE BELOW ------------ */}}
{{/* Set Up Variables */}}
{{ $reactionEmoji := .Reaction.Emoji.MessageFormat }}
{{ $reactionName := .Reaction.Emoji.Name }}
{{ $messageAuthor := .ReactionMessage.Author.ID }}
{{ $emojiCount := 0 }}
{{ $messageID := .Reaction.MessageID }}
{{range .ReactionMessage.Reactions}}
{{/* If emote name begins with 'bg' */}}
{{if reFind "^bg" $reactionName}}
{{/* Update count with the count of the emote */}}
{{$emojiCount = .Count}}
{{end}}
{{end}}
{{/* Form PokeNav Badge Command Strings */}}
{{ $commandGrantBadge := print "!gb " $reactionEmoji " " $messageAuthor }}
{{ $commandRevokeBadge := print "!rb " $reactionEmoji " " $messageAuthor }}
{{if reFind "^bg" $reactionName }} {{/* check that badge name starts with "bg" */}}
{{if .ReactionAdded }}
{{if eq $emojiCount 1}}
{{sendMessage $commandChannelID $commandGrantBadge }} {{/* sends gb command */}}
{{addReactions $checkEmoji}} {{/* adds check emoji to message */}}
{{end}}
{{else}}
{{if eq $emojiCount 0}}
{{sendMessage $commandChannelID $commandRevokeBadge }} {{/* sends rb command */}}
{{deleteMessageReaction $channelID $messageID $YAGid $checkEmoji}}
{{end}}
{{end}}
{{end}}