-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathregex.yag
32 lines (29 loc) · 1.28 KB
/
regex.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
{{/*
Trigger type: Regex
Trigger: \A
Copyright (c): Black Wolf, 2022
License: MIT
Repository: https://github.com/BlackWolfWoof/yagpdb-cc/
*/}}
{{/*NOTE: YOU NEED THE 'sticky message 2 command.gtmpl' CODE FOR THIS TO WORK*/}}
{{$whitelist := false}}
{{/*This enables the whitelist of channels where it should run*/}}
{{$channels := cslice 166207328570441728 384011387132706816}}
{{/*Replace these channel id's with your channels if you have enabled the whitelist*/}}
{{if not $whitelist}}{{$channels = cslice .Channel.ID}}{{end}}
{{if and ($db := dbGet 0 "stickymessage") (in $channels .Channel.ID)}}
{{$message := cembed "author" (sdict "name" (print "Sticky message by " $db.Value.author) "icon_url" "https://cdn.discordapp.com/emojis/587253903121448980.png") "color" $db.Value.color "description" $db.Value.message "image" (sdict "url" (or $db.Value.img ""))}}
{{$sm := dbGet .Channel.ID "smchannel"}}
{{$send := false}}
{{if not $sm}}
{{$send = true}}
{{else if currentTime.After $sm.Value.time}}
{{deleteMessage nil (toInt $sm.Value.id) 0}}
{{$send = true}}
{{end}}
{{if $send}}
{{$id := sendMessageRetID nil $message}}
{{$dur := toDuration (or $db.Value.cooldown "0s")}}
{{dbSet .Channel.ID "smchannel" (sdict "time" (currentTime.Add $dur) "id" (str $id))}}
{{end}}
{{end}}