From 88d22e2a58a15fec7ccb854d09e2de16de850f34 Mon Sep 17 00:00:00 2001 From: duncte123 Date: Mon, 2 Oct 2023 15:06:36 +0200 Subject: [PATCH 1/2] Fix DUNCTEBOT-11E --- .../duncte123/skybot/commands/music/SkipCommand.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/bot/src/main/kotlin/ml/duncte123/skybot/commands/music/SkipCommand.kt b/bot/src/main/kotlin/ml/duncte123/skybot/commands/music/SkipCommand.kt index bf3721088..c92f7265b 100644 --- a/bot/src/main/kotlin/ml/duncte123/skybot/commands/music/SkipCommand.kt +++ b/bot/src/main/kotlin/ml/duncte123/skybot/commands/music/SkipCommand.kt @@ -69,11 +69,16 @@ class SkipCommand : MusicCommand() { doSkip(mng, sendMessage) return } + + val vc = getLavalinkManager().getConnectedChannel(guild) + + if (vc == null) { + sendMessage("Somehow I am not connected to a voice channel? Probably a bug, please report this!") + return + } // https://github.com/jagrosh/MusicBot/blob/master/src/main/java/com/jagrosh/jmusicbot/commands/music/SkipCmd.java - val listeners = getLavalinkManager() - .getConnectedChannel(guild) - .members.filter { + val listeners = vc.members.filter { !it.user.isBot && !(it.voiceState?.isDeafened ?: false) }.count() @@ -86,8 +91,7 @@ class SkipCommand : MusicCommand() { "$YES_STATIC Successfully voted to skip the song `[" } - val skippers = getLavalinkManager().getConnectedChannel(guild) - .members.count { votes.contains(it.idLong) } + val skippers = vc.members.count { votes.contains(it.idLong) } val required = ceil(listeners * .55).toInt() msg += "$skippers votes, $required/$listeners needed]`" From d4ea527feed81765bb2ebea1b6d352151587b57c Mon Sep 17 00:00:00 2001 From: duncte123 Date: Sun, 8 Oct 2023 10:36:03 +0200 Subject: [PATCH 2/2] Lint code --- .../duncte123/skybot/commands/music/SkipCommand.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bot/src/main/kotlin/ml/duncte123/skybot/commands/music/SkipCommand.kt b/bot/src/main/kotlin/ml/duncte123/skybot/commands/music/SkipCommand.kt index c92f7265b..deeb55c9e 100644 --- a/bot/src/main/kotlin/ml/duncte123/skybot/commands/music/SkipCommand.kt +++ b/bot/src/main/kotlin/ml/duncte123/skybot/commands/music/SkipCommand.kt @@ -70,17 +70,17 @@ class SkipCommand : MusicCommand() { return } - val vc = getLavalinkManager().getConnectedChannel(guild) + val vc = getLavalinkManager().getConnectedChannel(guild) - if (vc == null) { - sendMessage("Somehow I am not connected to a voice channel? Probably a bug, please report this!") - return - } + if (vc == null) { + sendMessage("Somehow I am not connected to a voice channel? Probably a bug, please report this!") + return + } // https://github.com/jagrosh/MusicBot/blob/master/src/main/java/com/jagrosh/jmusicbot/commands/music/SkipCmd.java val listeners = vc.members.filter { - !it.user.isBot && !(it.voiceState?.isDeafened ?: false) - }.count() + !it.user.isBot && !(it.voiceState?.isDeafened ?: false) + }.count() val votes = trackData.votes