diff --git a/command_tag.go b/command_tag.go index b95604b..ccfc6c0 100644 --- a/command_tag.go +++ b/command_tag.go @@ -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", diff --git a/main.go b/main.go index 4d862b6..86da019 100644 --- a/main.go +++ b/main.go @@ -55,3 +55,7 @@ func main() { defer removeCommandFromAllGuilds(discord) discord.Close() } + +func int64Ptr(i int64) *int64 { + return &i +} diff --git a/register_commands.go b/register_commands.go index 07a8411..2ce1db5 100644 --- a/register_commands.go +++ b/register_commands.go @@ -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 +} +*/