Milen/util/perm.go

21 lines
443 B
Go

package util
import (
"github.com/bwmarrin/discordgo"
"gitea.teamortix.com/chanbakjsd/Milen/humanify"
)
func RequireAdmin(dg *discordgo.Session, userID string, channelID string, hasAdmin func()) {
perm, err := dg.UserChannelPermissions(userID, channelID)
if err != nil {
ReportError(dg, err)
return
}
if perm&discordgo.PermissionAdministrator == 0 {
SendCheckError(dg, channelID, humanify.Eng.NoAdmin)
return
}
hasAdmin()
}