added permission management
This commit is contained in:
@@ -8,8 +8,9 @@ import (
|
||||
|
||||
var tag_command Command = Command{
|
||||
Definition: discordgo.ApplicationCommand{
|
||||
Name: "tag",
|
||||
Description: "A command to show and edit saved presaved messages.",
|
||||
Name: "tag",
|
||||
DefaultMemberPermissions: int64Ptr(discordgo.PermissionManageServer),
|
||||
Description: "A command to show and edit saved presaved messages.",
|
||||
Options: []*discordgo.ApplicationCommandOption{
|
||||
{
|
||||
Name: "get",
|
||||
|
4
main.go
4
main.go
@@ -55,3 +55,7 @@ func main() {
|
||||
defer removeCommandFromAllGuilds(discord)
|
||||
discord.Close()
|
||||
}
|
||||
|
||||
func int64Ptr(i int64) *int64 {
|
||||
return &i
|
||||
}
|
||||
|
@@ -68,3 +68,36 @@ func removeCommandFromAllGuilds(s *discordgo.Session) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func hasManageServerPermissions(s *discordgo.Session, userID string, guildID string) bool {
|
||||
member, err := s.GuildMember(guildID, userID)
|
||||
if err != nil {
|
||||
fmt.Printf("Error fetching guild member: %v\n", err)
|
||||
return false
|
||||
}
|
||||
|
||||
guild, err := s.Guild(guildID)
|
||||
if err != nil {
|
||||
fmt.Printf("Error fetching guild: %v\n", err)
|
||||
return false
|
||||
}
|
||||
|
||||
if guild.OwnerID == userID {
|
||||
return true
|
||||
}
|
||||
|
||||
for _, roleID := range member.Roles {
|
||||
role, err := s.State.Role(guildID, roleID)
|
||||
if err != nil {
|
||||
fmt.Printf("Error fetching role: %v\n", err)
|
||||
continue
|
||||
}
|
||||
if role.Permissions&discordgo.PermissionManageServer != 0 || role.Permissions&discordgo.PermissionAdministrator != 0 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
*/
|
||||
|
Reference in New Issue
Block a user