forked from BlackWolfWoof/yagpdb-cc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbresetall.yag
68 lines (65 loc) · 4.09 KB
/
dbresetall.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
{{/*
Trigger: dbresetall
Trigger Type: Command
Usage:
dbresetall
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 not .ExecData}}
{{$prefix := index (reFindAllSubmatches `Prefix of \x60\d+\x60: \x60(.+)\x60` (exec "prefix")) 0 1}}
{{if (in (split (index (split (exec "viewperms") "\n") 2) ", ") $perms)}}
{{if eq (len .CmdArgs) 0}}
{{$cslice := split "abcdefghijklmnopqrstuvwxyz" ""|shuffle}}
{{$random := ""}}{{range (seq 0 10)}}{{$r := index (shuffle (cslice 0 1)) 0}}{{if eq $r 1}}{{$random = print $random (upper (index $cslice .))}}{{else}}{{$random = print $random (index $cslice .)}}{{end}}{{end}}
{{$x := sendMessageRetID nil (cembed "title" "Hold up!" "description" (print "**YOU ARE ABOUT TO DELETE THE `ENTIRE` YAGPDB DATABASE (`" dbCount "` ENTRIES) ON THIS SERVER\n\nARE YOU SURE YOU WANT TO DO THIS?**\n**❗There is no going back once you confirmed❗**\n\n__If you still want to proceed type__") "footer" (sdict "text" (print $prefix "dbresetall " $random) "icon_url" "https://cdn.discordapp.com/emojis/650328464825516062.png") "color" 0xBE1931 "thumbnail" (sdict "url" "https://cdn.discordapp.com/emojis/565142262401728512.png"))}}
{{dbSetExpire .User.ID "dbresetall" (sdict "code" $random "msgid" $x) 60}}
{{deleteMessage nil $x 60}}
{{else}}
{{with (dbGet .User.ID "dbresetall").Value}}
{{if eq $.StrippedMsg .code}}
{{$x := sendMessageRetID nil (cembed "author" (sdict "icon_url" "https://cdn.discordapp.com/emojis/714051544265392229.gif" "name" (print "This might take a while... (0/" dbCount ")")) "description" "Please wait until the command is done running.\n**Do not run dbresetall again until it is finished!**\nYou will be pinged if the reset is done :)" "color" 0xFAA61A)}}
{{execCC $.CCID nil 6 (sdict "id" $x "all" dbCount "time" currentTime "count" 0)}}
{{deleteTrigger 1}}
{{deleteMessage nil .msgid 0}}
{{else}}
{{sendMessage nil (print "Wrong code provided. Use `" $prefix "dbresetall` to get a new code")}}
{{end}}
{{else}}
{{sendMessage nil (print "Wrong code provided. Use `" $prefix "dbresetall` to get a new code")}}
{{end}}
{{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}}
{{else}}
{{$c := 1}}
{{$count := 0}}
{{if .IsPremium}}
{{range (seq 0 9)}}
{{- if ne $c 0 -}}
{{- $c = dbDelMultiple (sdict "pattern" "%") 100 0 -}}
{{- $count = add $count $c -}}
{{- end -}}
{{end}}
{{else}}
{{$count = dbDelMultiple (sdict "pattern" "%") 100 0}}
{{end}}
{{$dbcount := dbCount}}
{{$sdict := .ExecData}}
{{$sdict.Set "count" (add $count $sdict.count)}}
{{if ne $dbcount 0}}
{{editMessage nil $sdict.id (cembed "author" (sdict "icon_url" "https://cdn.discordapp.com/emojis/714051544265392229.gif" "name" (print "This might take a while... (" (sub .ExecData.all $dbcount) "/" .ExecData.all ")")) "description" "Please wait until the command is done running.\n**Do not run dbresetall again until it is finished!**\nYou will be pinged if the reset is done :)" "color" 0xFAA61A)}}
{{execCC .CCID nil 8 $sdict}}
{{else}}
{{sendMessage nil (complexMessage "content" .User.Mention "embed" (cembed
"title" "I am done resetting the database! <:wolfyey:664130162023202816>"
"description" (print "Deleted entries: " $sdict.count "\nExpired time: " (toDuration (print ((currentTime.Sub $sdict.time).Seconds|roundCeil) "s")))
"color" 0x43B581))}}
{{deleteMessage nil $sdict.id 0}}
{{end}}
{{end}}