Skip to content

Commit

Permalink
fix: title not reset on afk (#53)
Browse files Browse the repository at this point in the history
* fix: title not reset on afk

* fix: title not reset on afk (unstaged)

* fix: reset title on move

Co-authored-by: Tomachi <8929706+book000@users.noreply.github.com>

* fix: remove unused variable

---------

Co-authored-by: Tomachi <8929706+book000@users.noreply.github.com>
  • Loading branch information
yuuahp and book000 authored Nov 9, 2023
1 parent 8eefad1 commit 18ccdab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/com/jaoafa/vcspeaker/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class Main : CliktCommand() {
add(::VoiceJoinEvent)
add(::VoiceLeaveEvent)
add(::VoiceMoveEvent)
add(::TitleEvent)
add(::TitleResetEvent)
add(::SelfVoiceJoinEvent)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.jaoafa.vcspeaker.features.Title.resetTitle
import com.jaoafa.vcspeaker.stores.GuildStore
import com.jaoafa.vcspeaker.tools.discord.DiscordExtensions.asChannelOf
import com.jaoafa.vcspeaker.tools.discord.DiscordExtensions.authorOf
import com.jaoafa.vcspeaker.tools.discord.DiscordExtensions.isAfk
import com.jaoafa.vcspeaker.tools.discord.DiscordExtensions.successColor
import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.event
Expand All @@ -12,14 +13,14 @@ import dev.kord.core.entity.channel.TextChannel
import dev.kord.core.event.user.VoiceStateUpdateEvent
import kotlinx.coroutines.flow.count

class TitleEvent : Extension() {
class TitleResetEvent : Extension() {
override val name = this::class.simpleName!!

override suspend fun setup() {
event<VoiceStateUpdateEvent> {
check {
failIf(event.state.getMember().isBot)
failIf(event.old?.getChannelOrNull() == null || event.state.getChannelOrNull() != null)
failIf(event.old?.getChannelOrNull() == null)
failIf(event.old?.getChannelOrNull()?.voiceStates?.count { !it.getMember().isBot } != 0)
}

Expand Down

0 comments on commit 18ccdab

Please sign in to comment.