Skip to content

Commit

Permalink
Prevent ArrayCancellation Exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
NoComment1105 committed Jan 14, 2023
1 parent 2e952a5 commit 8b9d849
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.hyacinthbots.lilybot.extensions.config

import com.kotlindiscord.kord.extensions.checks.guildFor
import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.event
import dev.kord.core.event.guild.GuildCreateEvent
Expand All @@ -25,7 +26,10 @@ class GuildLogging : Extension() {
*/
event<GuildDeleteEvent> {
action {
GuildLeaveTimeCollection().setLeaveTime(event.guildId, Clock.System.now())
val guildId = guildFor(event)?.asGuildOrNull()?.id
if (guildId != null) {
GuildLeaveTimeCollection().setLeaveTime(guildId, Clock.System.now())
}
}
}

Expand All @@ -37,7 +41,10 @@ class GuildLogging : Extension() {
*/
event<GuildCreateEvent> {
action {
GuildLeaveTimeCollection().removeLeaveTime(event.guild.id)
val guildId = guildFor(event)?.asGuildOrNull()?.id
if (guildId != null) {
GuildLeaveTimeCollection().removeLeaveTime(guildId)
}
}
}
}
Expand Down

0 comments on commit 8b9d849

Please sign in to comment.