-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathattachment-Limiter.go
60 lines (53 loc) · 2.02 KB
/
attachment-Limiter.go
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
{{/*
Trigger Type: Regex (Channel Restricted); Trigger: \A
Copyright: Lofty | Brambles, 2021
License: MIT
Repository: https://github.com/Lofty-Brambles/some-yagpdb-cc */}}
{{/* Config starts */}}
{{ $emojis := cslice "🚒"}}{{/* If you want to add emojis, add them. If not, keep empty. */}}
{{ $max := 1 }}{{/* Max attachments for default user */}}
{{ $limits := sdict "123" "1" "123" "3" "947954288909488190" "bypass" }}{{/* Add Role ID - limit pairs. "bypass" will remove limit.*/}}
{{/* Config ends */}}
{{/* Setting variables */}}
{{ $count := 0 }}{{ $messageObj := .Message }}
{{ $del := false }}{{ $role := "0" }}
{{/* Fetching attachments */}}
{{ if $embs := $messageObj.Embeds }}
{{ range $embs }}
{{ if .Thumbnail }}{{ $count = add $count 1 }}{{ end }}
{{ if .Image }}{{ $count = add $count 1 }}{{ end }}
{{ end }}
{{ else if $att := $messageObj.Attachments }}
{{ $count = len $att | add $count }}
{{ end }}
{{/* Comparing limits */}}
{{ range $k, $v := $limits }}
{{ if and ( toInt $k | hasRoleID ) ( gt ( toInt $k ) $max ) }}
{{ $temp := $v }}
{{ if eq $temp "bypass" }}
{{ $max = 999999999 }}
{{ else }}
{{ $max = toInt $temp }}
{{ end }}
{{ $role = $k }}
{{ end }}
{{ end }}
{{ if gt $count $max }}
{{ $del = true }}
{{ end }}
{{/* Sending out de outputs */}}
{{ $rolemessage := "" }}
{{ if ne $role "0" }}
{{ $rolemessage = print ", because of you having the <@" $role "> role" }}
{{ end }}
{{ if eq $del true }}
{{ deleteMessage nil .Message.ID 0 }}
{{ $id := sendMessageRetID nil ( complexMessage "content" .User.Mention "embed" ( cembed
"title" "Warning"
"description" ( print "> <:scross:963688138155388978> | Your message was __deleted!__\nYou have been allowed to post a maximum of " $max " attachments" $rolemessage "!" )
"color" 0x2e3137
"timestamp" currentTime ) ) }}
{{ deleteMessage nil $id 10 }}
{{ else }}
{{ range $emojis }}{{ addReactions . }}{{ end }}
{{ end }}