-
Notifications
You must be signed in to change notification settings - Fork 66
/
dball.yag
43 lines (40 loc) · 2.63 KB
/
dball.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
{{/*
Trigger: dball
Trigger Type: Command
Usage:
dball
dball page
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*/}}
{{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 0 (print $prefix "dball <Page (optional)>")
(carg "int" "page")}}
{{$page := 0}}{{$c := 0}}
{{if ($args.Get 0)}}{{$page = mult (add ($args.Get 0) -1) 10}}{{end}}
{{$x := sendMessageRetID nil (cembed "author" (sdict "name" (print "Loading results...") "icon_url" "https://cdn.discordapp.com/emojis/585829014384541716.gif"))}}
{{$total := dbCount}}
{{$count := add $page 1}}
{{$fields := cslice (sdict "name" "**• Searching Info:**" "value" (print "Total Results: " $total) "inline" false)}}
{{- range (dbTopEntries "%" 10 $page)}}
{{- $value := json .Value}}
{{- if gt (len $value) 30}}{{$value = print (slice $value 0 30) "..."}}{{end}}
{{- $userm := .UserID}}
{{- with (getMember .UserID)}}{{$userm = print .User.Mention " `" .User.String "`"}}{{end}}
{{- $fields = $fields.Append (sdict "name" (print "**#" $count " Search Result:**") "value" (print "User: " $userm "\nKey name: " .Key "\nKey ID: " .ID "\nType: `" (printf "%T" .Value) "`\nCharacters: " (len (json .Value)) "/100000\nSize: " (printf "%.2f" (fdiv (len (json .Value)) 1000)) "kB\nValue:\n```json\n" (reReplace `\\\\` $value `\`) "```") "inline" false)}}
{{- $count = add $count 1}}{{$c = add $c 1}}
{{- end}}
{{$embed := sdict "title" "📄 Database entries" "color" 0x00D66C "fields" $fields}}
{{if eq $c 0}}
{{editMessage nil $x (complexMessageEdit "embed" (cembed "title" "Something unexpected happened :(" "description" "<:cross:705738821110595607> This site doesn't exist or is empty!" "color" 0xDD2E44))}}
{{else}}
{{editMessage nil $x (complexMessageEdit "embed" (cembed $embed))}}
{{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}}