added permission management
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
|||||||
var tag_command Command = Command{
|
var tag_command Command = Command{
|
||||||
Definition: discordgo.ApplicationCommand{
|
Definition: discordgo.ApplicationCommand{
|
||||||
Name: "tag",
|
Name: "tag",
|
||||||
|
DefaultMemberPermissions: int64Ptr(discordgo.PermissionManageServer),
|
||||||
Description: "A command to show and edit saved presaved messages.",
|
Description: "A command to show and edit saved presaved messages.",
|
||||||
Options: []*discordgo.ApplicationCommandOption{
|
Options: []*discordgo.ApplicationCommandOption{
|
||||||
{
|
{
|
||||||
|
|||||||
4
main.go
4
main.go
@@ -55,3 +55,7 @@ func main() {
|
|||||||
defer removeCommandFromAllGuilds(discord)
|
defer removeCommandFromAllGuilds(discord)
|
||||||
discord.Close()
|
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