-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathdbgetmap.yag
77 lines (73 loc) · 5.03 KB
/
dbgetmap.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
74
75
76
77
{{/*
Trigger: dbgetmap
Trigger Type: Command
Usage:
dbgetmap ID/Mention Key SdictName
Copyright (c): Black Wolf, 2021
License: MIT
Repository: https://github.com/BlackWolfWoof/yagpdb-cc/
*/}}
{{$perms := "Administrator"}}
{{/*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*/}}
{{define "time"}}
{{$days := fdiv (currentTime.Sub .time).Hours 24}}{{$human := currentTime.Sub .time|humanizeDurationSeconds}}
{{if currentTime.Before .time}}
{{$days = fdiv (.time.Sub currentTime).Hours 24}}{{$human = .time.Sub currentTime|humanizeDurationSeconds}}
{{end}}
{{$y := fdiv $days 365.25|roundFloor|toFloat}}
{{$mo := (sub (fdiv $days 30.417) (mult $y 12))|roundFloor|toFloat}}
{{$d := toFloat (sub $days (add (mult $y 365.25) (mult $mo 30.417)))}}
{{.Set "e" (print "🗓️<t:" .time.Unix ":d> ⏱️<t:" .time.Unix ":T>\u200A⌛\u200A" (toInt $y) "Y " (toInt $mo) "M " (toInt $d) "D\n" $human " ago")}}
{{end}}
{{if (in (split (index (split (exec "viewperms") "\n") 2) ", ") $perms)}}
{{$prefix := index (reFindAllSubmatches `Prefix of \x60\d+\x60: \x60(.+)\x60` (exec "prefix")) 0 1}}
{{$args := parseArgs 3 (print $prefix "dbgetmap <ID/Mention> <Key> <SdictName>")
(carg "userid" "id")
(carg "string" "key")
(carg "string" "sdictname")}}
{{$t1 := (dbGet ($args.Get 0) ($args.Get 1))}}
{{if $t1}}
{{$db := sdict $t1.Value}}
{{if $db.Get ($args.Get 2)}}
{{$var2 := reReplace `\\\\` (json ($db.Get ($args.Get 2))) `\`}}
{{$embed := sdict "title" "📤 Database Info" "color" 0x00D66C "fields" (cslice (sdict "name" "**• Key Name:**" "value" (str $t1.Key) "inline" true) (sdict "name" "**• Key ID:**" "value" (str $t1.ID) "inline" true) (sdict "name" "**• User ID:**" "value" (str $t1.UserID) "inline" true) (sdict "name" "**• Sdict Name:**" "value" ($args.Get 2) "inline" true) (sdict "name" "**• Sdict Value Info:**" "value" (print "Type: `" (printf "%T" ($db.Get ($args.Get 2))) "`\nCharacters: " (len $var2) "/" (add (len $var2) (reReplace `\\\\` (json $db) `\`|len|sub 100000)) "\nSize: " (printf "%.2f" (fdiv (len $var2) 1000)) "kB") "inline" true))}}
{{$x := ""}}{{$out := print $var2}}{{$valuestr := sdict}}
{{if or (gt (len $var2) 999) (gt (urlescape $out|len|add 119) 1024)}}
{{$x = sendMessageRetID nil (complexMessage "file" $var2)}}
{{$out = (index (getMessage nil $x).Attachments 0).URL}}
{{$embed.Set "author" (sdict "name" "Value above" "icon_url" "https://cdn.discordapp.com/emojis/716314785985331250.gif")}}
{{else}}
{{$x = sendMessageRetID nil (cembed "title" "Loading...")}}
{{$embed.Set "footer" (sdict "text" "Value above" "icon_url" "https://cdn.discordapp.com/emojis/716314785985331250.gif")}}
{{$valuestr = sdict "name" "**• Value:**" "value" (print "```json\n" $var2 "```") "inline" false}}
{{end}}
{{$fields := $embed.fields.Append (sdict "name" "**• JSON Formatter:**" "value" (print "<:download:715520359729987635> [Formatted JSON](https://jsonformatter.curiousconcept.com/?process=true&spec=skip&data=" (urlescape $out) ")") "inline" true)}}
{{with (userArg $t1.UserID)}}{{$embed.Set "thumbnail" (sdict "url" (print "https://cdn.discordapp.com/avatars/" .ID "/" .Avatar ".png?size=4096"))}}{{$fields = $fields.Append (sdict "name" "**• User:**" "value" (print .Mention " `" .String "`") "inline" true)}}{{end}}
{{$e := sdict "time" $t1.CreatedAt}}
{{template "time" $e}}
{{$fields := $fields.Append (sdict "name" "**• Created at:**" "value" $e.e "inline" false)}}
{{if ne $t1.UpdatedAt.Unix $t1.CreatedAt.Unix}}
{{$e := sdict "time" $t1.UpdatedAt}}
{{template "time" $e}}
{{$fields = $fields.Append (sdict "name" "**• Updated at:**" "value" $e.e "inline" true)}}
{{end}}
{{if ne $t1.ExpiresAt.Unix -62135596800}}
{{$e := sdict "time" $t1.ExpiresAt}}
{{template "time" $e}}
{{$fields = $fields.Append (sdict "name" "**• Expires at:**" "value" $e.e "inline" true)}}
{{end}}
{{if $valuestr}}
{{$fields = $fields.Append $valuestr}}
{{end}}
{{$embed.Set "fields" $fields}}
{{editMessage nil $x (complexMessageEdit "embed" (cembed $embed))}}
{{else}}
{{sendMessage nil (cembed "color" 0xDD2E44 "title" "Something unexpected happened! :(" "description" "<:cross:705738821110595607> This database entry map name doesn't exist!")}}
{{end}}
{{else}}
{{sendMessage nil (cembed "color" 0xDD2E44 "title" "Something unexpected happened! :(" "description" "<:cross:705738821110595607> This database entry doesn't exist!")}}
{{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}}