Milen/util/perm.go

21 lines
443 B
Go

2020-05-11 05:30:07 +07:00
package util
import (
"github.com/bwmarrin/discordgo"
"gitea.teamortix.com/chanbakjsd/Milen/humanify"
2020-05-11 05:30:07 +07:00
)
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)
2020-05-11 05:30:07 +07:00
return
}
hasAdmin()
}