Test pointer panic

master
DustyP 6 years ago
parent 3eb47eda9c
commit ecbe2e958f

@ -24,15 +24,15 @@ func CheckPermissions(session *discordgo.Session, member discordgo.Member, chann
return true // If no permissions are required then just return true return true // If no permissions are required then just return true
} }
for _, overwrite := range channel.PermissionOverwrites { //for _, overwrite := range channel.PermissionOverwrites {
if overwrite.ID == member.User.ID { // if overwrite.ID == member.User.ID {
if overwrite.Allow&int(perms) != 0 { // if overwrite.Allow & int(perms) != 0 {
return true // If the channel has an overwrite for the user then true // return true // If the channel has an overwrite for the user then true
} else if overwrite.Deny&int(perms) != 0 { // } else if overwrite.Deny & int(perms) != 0 {
return false // If there is an explicit deny then false // return false // If there is an explicit deny then false
} // }
} // }
} //}
for _, roleID := range member.Roles { for _, roleID := range member.Roles {
role, err := session.State.Role(member.GuildID, roleID) role, err := session.State.Role(member.GuildID, roleID)
@ -40,15 +40,15 @@ func CheckPermissions(session *discordgo.Session, member discordgo.Member, chann
return false // There is something wrong with the role, default to false return false // There is something wrong with the role, default to false
} }
for _, overwrite := range channel.PermissionOverwrites { //for _, overwrite := range channel.PermissionOverwrites {
if overwrite.ID == roleID { // if overwrite.ID == roleID {
if overwrite.Allow&int(perms) != 0 { // if overwrite.Allow & int(perms) != 0 {
return true // If the channel has an overwrite for the role then true // return true // If the channel has an overwrite for the role then true
} else if overwrite.Deny&int(perms) != 0 { // } else if overwrite.Deny & int(perms) != 0 {
return false // If there is an explicit deny then false // return false // If there is an explicit deny then false
} // }
} // }
} //}
if role.Permissions&int(PermissionAdministrator) != 0 { if role.Permissions&int(PermissionAdministrator) != 0 {
return true // If they are an administrator then they automatically have all permissions return true // If they are an administrator then they automatically have all permissions

Loading…
Cancel
Save