-
Notifications
You must be signed in to change notification settings - Fork 66
/
command.yag
48 lines (41 loc) · 2.61 KB
/
command.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
{{/*
Trigger type: Command
Trigger: sm
Enable sticky message: sm This is a test
Disable sticky message: sm
If you still don't get how it works look at thi gif: https://i.imgur.com/ohRubPw.gif
Copyright (c): Black Wolf, 2022
License: MIT
Repository: https://github.com/BlackWolfWoof/yagpdb-cc/
*/}}
{{/*NOTE: YOU NEED THE 'sticky message 2' CODE FOR THIS TO WORK*/}}
{{$perms := "ManageMessages"}}
{{/*The bot will check if the user has this permission.
Permissions available: Administrator, ManageServer, ReadMessages, SendMessages, SendTTSMessages, ManageMessages, EmbedLinks, AttachFiles, ReadMessageHistory, MentionEveryone, VoiceConnect, VoiceSpeak, VoiceMuteMembers, VoiceDeafenMembers, VoiceMoveMembers, VoiceUseVAD, ManageNicknames, ManageRoles, ManageWebhooks, ManageEmojis, CreateInstantInvite, KickMembers, BanMembers, ManageChannels, AddReactions, ViewAuditLogs*/}}
{{$cooldown := "60s"}}{{/*FORMAT EXAMPLE: "10s" "20m10s" "1mo10d" "3w2h"*/}}
{{/*The default cooldown is how long the sticky message shouldn't be sent in the same channel*/}}
{{if (in (split (index (split (exec "viewperms") "\n") 2) ", ") $perms)}}
{{if .StrippedMsg}}
{{$color := 0}}{{$old := 0}}{{range .Guild.Roles}}{{if and (in $.Member.Roles .ID) (ne .Color 0) (gt .Position $old)}}{{$old = .Position}}{{$color = .Color}}{{end}}{{end}}
{{$img := ""}}{{$text := .StrippedMsg}}
{{with reFindAllSubmatches `(?:(?P<TxtSnip1>(?:.*[\r\n]?){0,}))?(?:-img\s(?P<Link>(?:https?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:\/?#[\]@!\$&'\(\)\*\+,;=.]+))(?P<TxTSnip2>(?:.*[\r\n]?){0,})` $text}}
{{$img = index . 0 2}}
{{$text = print (index . 0 1) (index . 0 3)}}
{{end}}
{{with reFindAllSubmatches `\A((?:.|[\r\n])*)(-d\s(?P<Duration>(?:(?:\d+)?(?:months?|mo|minutes?|s|seconds?|m|hours?|h|days?|d|weeks?|w|years?|y|permanent|p)){1,}))(\s(?:.|[\r\n])*)?\z` $text}}
{{$cooldown = index . 0 3}}
{{$text = print (index . 0 1) (index . 0 4)}}
{{end}}
{{dbSet 0 "stickymessage" (sdict "message" $text "author" .User.String "color" $color "cooldown" $cooldown "img" $img)}}
{{sendMessage nil "The sticky message was enabled and saved!"}}
{{else}}
{{dbDel 0 "stickymessage"}}
{{range dbTopEntries "smchannel" 100 0}}
{{deleteMessage .UserID (toInt .Value.id) 0}}
{{end}}
{{$amount := dbDelMultiple (sdict "pattern" "smchannel") 100 0}}
{{sendMessage nil (print "Sticky messages are now disabled and deleted from " $amount " channel(s).")}}
{{end}}
{{else}}
{{sendMessage nil (cembed "title" "Missing permissions" "description" (print "<:cross:705738821110595607> You are missing the permission `" $perms "` to use this command!") "color" 0xDD2E44)}}
{{end}}