forked from BlackWolfWoof/yagpdb-cc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand.yag
73 lines (70 loc) · 2.79 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{{/*
Trigger type: Command
Trigger: poll
Copyright (c): Black Wolf, 2021
License: MIT
Repository: https://github.com/BlackWolfWoof/yagpdb-cc/
*/}}
{{/*When using poll as trigger make sure to disable the default poll command here --> https://i.imgur.com/8WlHqyo.gif*/}}
{{$num := dict 0 "1️⃣" 1 "2️⃣" 2 "3️⃣" 3 "4️⃣" 4 "5️⃣" 5 "6️⃣" 6 "7️⃣" 7 "8️⃣" 8 "9️⃣" 9 "🔟"}}
{{/*To replace the emojis you can do this as example:
Replace the keycap 1️⃣ with the emoji you like. If you wanna get the right emoji format use \:emoji: in chat to get it and then copy it.*/}}
{{if gt (.CmdArgs|len) 2}}
{{$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}}
{{$args := parseArgs 0 "" (carg "string" "") (carg "string" "") (carg "string" "") (carg "string" "") (carg "string" "") (carg "string" "") (carg "string" "") (carg "string" "") (carg "string" "") (carg "string" "")}}
{{$avatar := print (.User.AvatarURL "1024") "?single=false"}}
{{if (reFind `(?i)-single` .StrippedMsg)}}
{{$avatar = print $avatar "?single=true"}}
{{end}}
{{$x := sendMessageRetID nil (cembed
"title" "Poll loading... <a:discord_loading:714051544265392229>"
"color" $color
"author" (sdict "name" .User.String "icon_url" $avatar))}}
{{$desc := ""}}
{{$CmdArgs := cslice}}
{{range $c,$in := .CmdArgs}}
{{$dot := $in}}{{$sub := 0}}
{{$dot := reReplace `(?i)-single` $in ""}}
{{if ne $dot ""}}
{{if gt $c 10}}
{{$CmdArgs.Set (len $CmdArgs|add -1) (print (index $CmdArgs (len $CmdArgs|add -1|add $sub)) " " $dot)}}
{{else}}
{{$CmdArgs = $CmdArgs.Append $dot}}
{{end}}
{{end}}
{{end}}
{{range $c,$in := slice $CmdArgs 1 (len $CmdArgs)}}
{{- $emoji := ""}}
{{- if eq "" (index ($output := index (reFindAllSubmatches `^<?:?(?:(.+)>|(.+))?$` ($num.Get $c)) 0) 2)}}
{{- $emoji = index $output 1}}
{{- else}}
{{- $emoji = index $output 2}}
{{- end}}
{{- if hasPrefix $emoji `a:`}}
{{- $desc = print $desc "\n<" $emoji "> " $in}}
{{- else if reFind `\d+\z` $emoji}}
{{- $desc = print $desc "\n<:" $emoji "> " $in}}
{{- else}}
{{- $desc = print $desc "\n" $emoji " " $in}}
{{- end}}
{{- addMessageReactions nil $x $emoji}}
{{- end}}
{{$embed := sdict
"title" ($args.Get 0)
"description" $desc
"color" $color
"author" (sdict "name" .User.String "icon_url" $avatar)}}
{{if (reFind `(?i)-single` .StrippedMsg)}}
{{$embed.Set "footer" (sdict "text" "You can only choose one option")}}
{{end}}
{{editMessage nil $x (cembed $embed)}}
{{deleteTrigger 0}}
{{else}}
{{sendMessage nil (print "<:cross:705738821110595607>You need at least 2 options!\nExample: `" .Cmd " \"Example Title\" Yes No \"I don't know\" -single`")}}
{{end}}