Check for a role before adding to whitelist
Signed-off-by: AKP <tom@tdpain.net>
This commit is contained in:
parent
4e8100e1ed
commit
ce8dbcf668
2 changed files with 22 additions and 2 deletions
|
@ -25,8 +25,27 @@ func handleApplicationCommand(s *discordgo.Session, i *discordgo.InteractionCrea
|
|||
return
|
||||
}
|
||||
|
||||
username, ok := cmdData.Options[0].Value.(string)
|
||||
if !ok {
|
||||
rolesOk := false
|
||||
for _, roleID := range i.Member.Roles {
|
||||
if roleID == Config.RequiredRole {
|
||||
rolesOk = true
|
||||
}
|
||||
}
|
||||
|
||||
if !rolesOk {
|
||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
||||
Data: &discordgo.InteractionResponseData{
|
||||
Embeds: []*discordgo.MessageEmbed{
|
||||
{Description: "Not verified - please verify first.", Color: 0xff0000},
|
||||
},
|
||||
},
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
username, rolesOk := cmdData.Options[0].Value.(string)
|
||||
if !rolesOk {
|
||||
log.Error().Interface("val", cmdData.Options[0].Value).Msg("discord api string not a string??")
|
||||
return
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ var Config = &struct {
|
|||
ContainerName string `json:"containerName"`
|
||||
GuildID string `json:"guildID"`
|
||||
DockerSocket string `json:"dockerSocket"`
|
||||
RequiredRole string `json:"requiredRole"`
|
||||
}{}
|
||||
|
||||
func main() {
|
||||
|
|
Reference in a new issue