-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathpermission_check.yag
47 lines (33 loc) · 2.15 KB
/
permission_check.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
{{/*
Usage:
Everything bewteen the if and the else will be executed if the user has the permission you configured in the variable.
Choose bewteen permission check v1 and v2
v1: Use this if you just need to use the permission check one for the entire custom command
v2: Use this if you need to check for multiple permissions in the custom command
different channel: Specify a channel you want to get the permissions of a user from
Made by @blackwolfwoof
*/}}
{{/*The bot will check if the user has this permission.
Available permissions: Administrator, ManageServer, ReadMessages, SendMessages, SendTTSMessages, ManageMessages, EmbedLinks, AttachFiles, ReadMessageHistory, MentionEveryone, UseExternalEmojis, VoiceConnect, VoiceSpeak, VoiceMuteMembers, VoiceDeafenMembers, VoiceMoveMembers, VoiceUseVAD, ChangeNickname, ManageNicknames, ManageRoles, ManageWebhooks, ManageEmojis, CreateInstantInvite, KickMembers, BanMembers, ManageChannels, AddReactions, ViewAuditLogs*/}}
{{/*Permission Check v1*/}}
{{$perms := "Administrator"}}
{{if (in (split (index (split (exec "viewperms") "\n") 2) ", ") $perms)}}
{{/*Here you can add the code that will run if the user has the right permissions*/}}
{{else}}
{{sendMessage nil (cembed "title" "Missing permissions" "description" (print "<:cross:705738821110595607> You are missing the permission `" $perms "` to use this command!") "color" 0xDD2E44)}}
{{end}}
{{/*Permission Check v2*/}}
{{$perms := split (index (split (exec "viewperms" ) "\n" ) 2) ", "}}
{{if in $perms "Administrator"}}
{{/*Here you can add the code that will run if the user has the right permissions*/}}
{{end}}
{{if in $perms "ManageServer"}}
{{/*Here you can add the code that will run if the user has the right permissions*/}}
{{end}}
{{/*Permission Check in different channel*/}}
{{$perms := "Administrator"}}{{$channelID := 266290803125518336}}
{{define "perms"}}{{.TemplateArgs.Set "Out" (exec "viewperms")}}{{end}}
{{$permlist := sdict}}{{$v0 := sendTemplate $channelID "perms" $permlist}}
{{if (in (split (index (split $permlist.Out "\n" ) 2) ", ") $perms)}}
{{/*Here you can add the code that will run if the user has the right permissions*/}}
{{end}}