-
Notifications
You must be signed in to change notification settings - Fork 0
/
host-delete.yag
88 lines (74 loc) · 3.47 KB
/
host-delete.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
78
79
80
81
82
83
84
85
86
87
88
{{/*
Shiny/Hundo/Shundo Host Leaderboard
Trigger: host-delete
Trigger Type: Command (mention/cmd prefix)
Require Roles: roles who will delete entries
Restrict to channel for Mods to use command
deletes user's entries from database
!host-delete <type> <username/userID>
1st argument: hundo/shiny/shundo
2nd argument: username/userID
This deletes the database entry for a given user and type
Meant to be used when you want to remove it from Leaderboard
Confirmation messages are sent to the channel where command is used
Expecting it to be used in a private channel by moderators/admins
*/}}
{{/* Set up thumbnail images for confirmation messages*/}}
{{ $hundoThumbnail := "https://cdn.discordapp.com/emojis/749800513297449021.png?v=1" }}
{{ $shinyThumbnail := "https://cdn.discordapp.com/emojis/747623016829157461.gif?v=1" }}
{{ $shundoThumbnail := "https://cdn.discordapp.com/emojis/883800023689732116.gif?v=1" }}
{{ $errorThumbnail := "https://cdn.discordapp.com/emojis/642444935093813268.png?v=1" }}
{{/* ------------ DO NOT ALTER CODE BELOW ------------ */}}
{{/* Parsing and checking command arguments */}}
{{$args := parseArgs 2 "Syntax is *<hundo, shiny, shundo> <@user>* "
(carg "string" "choose from hundo, shiny or shundo")
(carg "userid" "username/userID of entry to delete")}}
{{/* Setting up variables from command arguments */}}
{{ $type := lower ($args.Get 0)}} {{/* Convert first argument to lower case and set variable*/}}
{{ $userID := ($args.Get 1)}} {{/* set 2nd argument as user variable */}}
{{ $user := (userArg $userID)}} {{/* gets user from ID */}}
{{ $mention := $user.Mention}} {{/* Make user into mention */}}
{{/* Checking $type variable for correct command */}}
{{ if eq $type "hundo"}}
{{addReactions ":white_check_mark:"}}
{{$v := dbDel $userID $type }} {{/* deletes Hundo entry for user */}}
{{$hundoCount := ((dbGet $userID "hundo").Value)}}
{{ $embed := cembed
"title" "Hundo Hosted Edited"
"description" (println "The Hundo Hosts for" $mention "has been edited. \n Total Hundos hosted to date is now" $hundoCount)
"thumbnail" (sdict "url" $hundoThumbnail )
"color" 4645612
}}
{{ sendMessage nil $embed }}
{{ else if eq $type "shiny"}}
{{addReactions ":white_check_mark:"}}
{{$v := dbDel $userID $type }} {{/* deletes Shiny entry for user */}}
{{$shinyCount := ((dbGet $userID "shiny").Value)}}
{{ $embed := cembed
"title" "Shiny Hosted Edited"
"description" (println "The Shiny Hosts for" $mention "has been edited. \n Total Shinies hosted to date is now" $shinyCount)
"thumbnail" (sdict "url" $shinyThumbnail )
"color" 4645612
}}
{{ sendMessage nil $embed }}
{{ else if eq $type "shundo"}}
{{addReactions ":white_check_mark:"}}
{{$v := dbDel $userID $type }} {{/* deletes Shundo entry for user */}}
{{$shundoCount := ((dbGet $userID "shundo").Value)}}
{{ $embed := cembed
"title" "Shundo Hosted Edited"
"description" (println "The Shundo Hosts for" $mention "has been edited. \n Total Shundos hosted to date is now" $shundoCount)
"thumbnail" (sdict "url" $shundoThumbnail )
"color" 4645612
}}
{{ sendMessage nil $embed }}
{{ else }}
{{addReactions "❌"}}
{{ $embed := cembed
"title" "Error Detected: invalid option."
"description" "The options are: \n- hundo \n- shiny \n- shundo"
"thumbnail" (sdict "url" $errorThumbnail )
"color" 4645612
}}
{{ sendMessage nil $embed }}
{{end}}