-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathdbuser.yag
45 lines (42 loc) · 3.07 KB
/
dbuser.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
{{/*
Trigger: dbuser
Trigger Type: Command
Usage:
dbuser ID/Mention 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 1 (print $prefix "dbuser <ID/Mention> <Page (optional)>")
(carg "userid" "id")
(carg "int" "page")}}
{{$id := $args.Get 0}}{{$userm := print "`" ($args.Get 0) "`"}}{{$users := ""}}
{{$user := userArg ($args.Get 0)}}{{with $user}}{{$userm = .Mention}}{{$users = print " `" .String "`"}}{{end}}
{{$page := 0}}{{$c := 0}}
{{if ($args.Get 1)}}{{$page = mult (add ($args.Get 1) -1) 10}}{{end}}
{{$x := sendMessageRetID nil (cembed "author" (sdict "name" (print "Loading results...") "icon_url" "https://cdn.discordapp.com/emojis/585829014384541716.gif"))}}
{{$total := dbGetPattern ($args.Get 0) "%" 100 0}}
{{if eq (len $total) 100}}{{$total = "100⩲"}}{{else}}{{$total = len $total}}{{end}}
{{$count := add $page 1}}
{{$fields := cslice (sdict "name" "**• Searching Info:**" "value" (print "User ID: " $id $users "\nTotal Results: " $total) "inline" true)}}
{{- range (dbGetPattern ($args.Get 0) "%" 10 $page)}}
{{- $value := json .Value}}
{{- if gt (len $value) 30}}{{$value = print (slice $value 0 30) "..."}}{{end}}
{{- $fields = $fields.Append (sdict "name" (print "**#" $count " Search Result:**") "value" (print "Key name: " .Key "\nKey ID: " .ID "\nType: `" (printf "%T" .Value) "`\nCharacters: " (len (reReplace `\\\\` (json .Value) `\`)) "/100000\nSize: " (printf "%.2f" (fdiv (len (reReplace `\\\\` (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 search: user" "color" 0x00D66C "fields" $fields}}
{{if $user}}{{$embed.Set "thumbnail" (sdict "url" (print "https://cdn.discordapp.com/avatars/" $user.ID "/" $user.Avatar ".png?size=4096"))}}{{end}}
{{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}}