add restriction to age roles
This commit is contained in:
parent
a99496377e
commit
943e9fcaba
14
command.go
14
command.go
@ -237,12 +237,26 @@ func echoMessage(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|||||||
func giveAgeRole(s *discordgo.Session, m *discordgo.MessageCreate) {
|
func giveAgeRole(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||||
Member, _ := s.GuildMember(config.ServerID, m.Author.ID)
|
Member, _ := s.GuildMember(config.ServerID, m.Author.ID)
|
||||||
dm, _ := s.UserChannelCreate(Member.User.ID)
|
dm, _ := s.UserChannelCreate(Member.User.ID)
|
||||||
|
required := mapset.NewSetWith("416184227672096780", "416184208470310922", "416184150404628480", "416184132473847810", "440996904948465664")
|
||||||
for command, role := range config.RoleCommands {
|
for command, role := range config.RoleCommands {
|
||||||
if m.Content == command {
|
if m.Content == command {
|
||||||
// Found the command that was triggered
|
// Found the command that was triggered
|
||||||
// This is a restriction imposed by my own wrapper,
|
// This is a restriction imposed by my own wrapper,
|
||||||
// but working around it is not actually necessary for performance and makes the code uglier in other places.
|
// but working around it is not actually necessary for performance and makes the code uglier in other places.
|
||||||
for _, newRole := range config.RoleCommands {
|
for _, newRole := range config.RoleCommands {
|
||||||
|
// check if the user has a twitch sub or any of the patreon roles
|
||||||
|
isAllowed := false
|
||||||
|
for _, curRole := range Member.Roles {
|
||||||
|
if required.Contains(curRole) {
|
||||||
|
isAllowed = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !isAllowed {
|
||||||
|
s.ChannelMessageSend(dm.ID, "Du kannst dir keine Rolle zuweisen, da weder Patreon noch Twitch mit deinem Account verlinkt ist oder du Selphy auf keiner dieser Plattformen unterstützt. Bei Problemen wende dich bitte an die `!mods`.")
|
||||||
|
log.Printf("Denied role %s to %s. User is neither patron nor sub.", roleName(s.State, newRole), userToString(m.Author))
|
||||||
|
return
|
||||||
|
}
|
||||||
for _, curRole := range Member.Roles {
|
for _, curRole := range Member.Roles {
|
||||||
// If the user already has one of the available roles, tell them and exit
|
// If the user already has one of the available roles, tell them and exit
|
||||||
if newRole == curRole {
|
if newRole == curRole {
|
||||||
|
Loading…
Reference in New Issue
Block a user