fix possible null pointer dereference in role assignment

This commit is contained in:
kageru 2019-06-12 23:51:49 +02:00
parent 3cdb5418ff
commit 6393950694
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2

@ -249,8 +249,16 @@ func echoMessage(s *discordgo.Session, m *discordgo.MessageCreate) {
}
func giveAgeRole(s *discordgo.Session, m *discordgo.MessageCreate) {
Member, _ := s.GuildMember(config.ServerID, m.Author.ID)
dm, _ := s.UserChannelCreate(Member.User.ID)
Member, err := s.GuildMember(config.ServerID, m.Author.ID)
if err != nil {
log.Printf("User could not be retrieved for role assignment\n%s", err)
return
}
dm, err := s.UserChannelCreate(Member.User.ID)
if err != nil {
log.Printf("Could not reply to user\n%s", err)
return
}
required := mapset.NewSetWith("416184227672096780", "416184208470310922", "416184150404628480", "416184132473847810", "440996904948465664")
for command, role := range config.RoleCommands {
if m.Content == command {