This repository has been archived by the owner on Nov 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdreams.go
72 lines (67 loc) · 2.45 KB
/
dreams.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
61
62
63
64
65
66
67
68
69
70
71
72
{{ $ch := 1200964297518497903 }}
{{ $minimum := 20 }}
{{ $cd := 600 }}
{{ $cmd := .Cmd }}
{{ $msg := trimSpace .StrippedMsg }}
{{ if not (getChannel $ch) }}
{{ sendMessage nil (print "**Error:** Please edit the command code and adjust `$ch` to a valid channel ID.") }}
{{ deleteTrigger 0 }}
{{ return }}
{{ end }}
{{ $type := sdict
"-dream" "dream"
"-confess" "confession"
}}
{{ $phrase := or ($type.Get (lower $cmd)) "dream" }}
{{ if $msg }}
{{ if gt (len $msg) $minimum }}
{{ $db := "dreams_confessions" }}
{{ $ccid := .CCID }}
{{ if not (dbGet $ccid $db) }}
{{ $note := print "Use " $cmd " to post your own " $phrase "." }}
{{ $embed := cembed
"title" (title $phrase)
"description" $msg
"color" 8421888
"footer" (sdict "text" $note)
}}
{{ sendMessage $ch $embed }}
{{ dbSetExpire $ccid $db "cooldown" $cd }}
{{ $cdText := print
"A global cooldown is active for 10 minutes, meaning no one can post a dream or a confession during that time." "\n\n"
"__This messaage will be deleted automatically when the cooldown is over__."
}}
{{ $cdEmbed := cembed
"title" "Cooldown"
"description" $cdText
"color" 11993101
}}
{{ $x := sendMessageRetID $ch $cdEmbed }}
{{ deleteMessage $ch $x $cd }}
{{ else }}
{{ $x := sendMessageRetID nil "There is a global 10 minutes cooldown per dream or confession." }}
{{ deleteMessage nil $x 10 }}
{{ end }}
{{ else }}
{{ $x := sendMessageRetID nil (print "Your " $phrase " post must contain at least " $minimum " characters.") }}
{{ deleteMessage nil $x 10 }}
{{ end }}
{{ deleteTrigger 0 }}
{{ else }}
{{ $usage := print "**Usage:**" "\n" "```" $cmd " your message```" }}
{{ $explain := print
"Had an interesting dream? Want to confess something? Share it with us by using this command, it will post your message in <#" $ch ">." "\n\n"
$usage "\n"
"**Explanation:**" "\n"
"- Once you use `" $cmd "` it will post your message in the relative channel." "\n"
"- Your message will be deleted instantly, leaving only the one in <#" $ch ">." "\n"
"- If the " $phrase " is less than " $minimum " characters, nothing will be posted." "\n"
"- A limit of one dream or confession every 10 minutes, globally." "\n"
"- Feel free to review the code of this command [here](https://github.com/Samillion/yagpdb-cc/tree/main/Dreams)."
}}
{{ $main := cembed
"title" (print (title $phrase) "s")
"description" $explain
}}
{{ sendMessage nil $main }}
{{ end }}