feat: Bot now skips Bot Users

Signed-off-by: moonleay <contact@moonleay.net>
This commit is contained in:
moonleay 2023-09-14 09:41:27 +02:00
parent 8a2d2be505
commit eee820917d
Signed by: moonleay
GPG key ID: 82667543CCD715FB

View file

@ -18,6 +18,7 @@
package net.moonleay.lilJudd.features package net.moonleay.lilJudd.features
import com.kotlindiscord.kord.extensions.utils.isNullOrBot
import dev.inmo.krontab.buildSchedule import dev.inmo.krontab.buildSchedule
import dev.inmo.krontab.doInfinity import dev.inmo.krontab.doInfinity
import dev.kord.common.Color import dev.kord.common.Color
@ -162,12 +163,15 @@ object AvailabilityManager : IFeature {
} }
mce.collect { memberchunkevent -> mce.collect { memberchunkevent ->
memberchunkevent.members.forEach { memberchunkevent.members.forEach {
if (!it.isNullOrBot()) { // Check if the member is a bot
Logger.out("Checking member ${it.id.value} (${it.username})") Logger.out("Checking member ${it.id.value} (${it.username})")
if (it.roleIds.contains(Snowflake(pnrd.hastimeroleid))) { if (it.roleIds.contains(Snowflake(pnrd.hastimeroleid))) {
it.removeRole(Snowflake(pnrd.hastimeroleid)) it.removeRole(Snowflake(pnrd.hastimeroleid))
Logger.out("Removed role from ${it.username}") // Removed the role Logger.out("Removed role from ${it.username}") // Removed the role
} }
} }
// I cant use continue here, because it does not work with .forEach
}
} }
Logger.out("Got through all members") Logger.out("Got through all members")