forked from BlackWolfWoof/yagpdb-cc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbsetmap_-_basic.yag
49 lines (45 loc) · 2.7 KB
/
dbsetmap_-_basic.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
{{/*
Trigger: dbsetmap
Trigger Type: Command
Usage:
dbsetmap ID/Mention Key SdictName SdictValue SdictValueType (Optional)
Modified by modderan#4609, Dav!dノᵈᶻ#7635
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*/}}
{{/* Set CARG Type */}}
{{$t := "string"}}
{{$cargs := (cslice "int" "float" "string" "user" "userid" "channel" "duration" "member")}}
{{if gt (len .Args) 5}}
{{$t = (index .CmdArgs 4) | lower}}
{{end}}
{{if and (in $cargs $t) (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 4 (print "Usage: " $prefix "dbsetmap <UserID:mention> <Key:text> <sdictName:text> <sdictValue:text> <sdictValueType:carg> (Optional and currently set to \"**" $t "**\")")
(carg "userid" "UserID")
(carg "string" "Keyname")
(carg "string" "name")
(carg $t "value")
(carg "string" "valueType")}}
{{$t1 := dbGet ($args.Get 0) ($args.Get 1)}}
{{$user := userArg ($args.Get 0)}}{{$userm := print "`" ($args.Get 0) "`"}}
{{with $user}}{{$userm = .Mention}}{{end}}
{{if $t1}}
{{$db := sdict $t1.Value}}
{{$db.Set ($args.Get 2) ($args.Get 3)}}
{{dbSet ($args.Get 0) ($args.Get 1) $db}}
{{$embed := sdict "color" 0x00D66C "title" "✏️ Created database map entry" "description" (print "<:checkmark:705738821425299527> Created `" ($args.Get 1) "` for " $userm " and saved it in `" ($args.Get 2) "`.")}}
{{if $user}}{{$embed.Set "thumbnail" (sdict "url" (print "https://cdn.discordapp.com/avatars/" ($args.Get 0) "/" $user.Avatar ".png?size=4096"))}}{{end}}
{{sendMessage nil (cembed $embed)}}
{{else}}
{{sendMessage nil (cembed "color" 0xDD2E44 "title" "Something unexpected happened! :(" "description" "<:cross:705738821110595607> This database entry doesn't exist!")}}
{{end}}
{{else if not (in $cargs $t)}}
{{(print ":warning: \"" $t "\" is an invalid <sdictValueType:carg>, it must be one of **" $cargs "**.")}}
{{else}}
{{sendMessage nil (cembed "title" "Missing permissions" "description" (print "<:cross:705738821110595607> You are missing the permission `" $perms "` to use this command!") "color" 0xDD2E44)}}
{{end}}