From b2c175dff652fb3c78d43243ea4c1a592858f5c2 Mon Sep 17 00:00:00 2001 From: Sakuya Kosugi Date: Wed, 29 Mar 2023 01:42:58 +0900 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E3=81=97=E3=81=AA=E3=81=84?= =?UTF-8?q?=E9=96=A2=E6=95=B0=E3=81=AA=E3=81=A9=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/dev/cosgy/textToSpeak/Listener.kt | 20 +++---------------- .../commands/general/AboutCommand.kt | 2 +- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/main/java/dev/cosgy/textToSpeak/Listener.kt b/src/main/java/dev/cosgy/textToSpeak/Listener.kt index e03c7e7..eeec07f 100644 --- a/src/main/java/dev/cosgy/textToSpeak/Listener.kt +++ b/src/main/java/dev/cosgy/textToSpeak/Listener.kt @@ -22,7 +22,6 @@ import com.sedmelluq.discord.lavaplayer.track.AudioTrack import dev.cosgy.textToSpeak.audio.AudioHandler import dev.cosgy.textToSpeak.audio.QueuedTrack import dev.cosgy.textToSpeak.utils.OtherUtil -import net.dv8tion.jda.api.entities.Message import net.dv8tion.jda.api.entities.channel.concrete.PrivateChannel import net.dv8tion.jda.api.events.guild.voice.GuildVoiceUpdateEvent import net.dv8tion.jda.api.events.session.ReadyEvent @@ -33,7 +32,6 @@ import org.slf4j.LoggerFactory import java.io.IOException import java.util.* import java.util.concurrent.TimeUnit -import java.util.function.Consumer class Listener(private val bot: Bot) : ListenerAdapter() { var log: Logger = LoggerFactory.getLogger(this.javaClass) @@ -70,7 +68,7 @@ class Listener(private val bot: Bot) : ListenerAdapter() { } catch (e: InterruptedException) { throw RuntimeException(e) } - bot.playerManager.loadItemOrdered(event.guild, file, ResultHandler(null, event)) + bot.playerManager.loadItemOrdered(event.guild, file, ResultHandler(event)) } if (event.channelLeft!!.members.size == 1 && event.channelLeft!!.members.contains(botMember)) { val handler = event.guild.audioManager.sendingHandler as AudioHandler? @@ -91,7 +89,7 @@ class Listener(private val bot: Bot) : ListenerAdapter() { } catch (e: InterruptedException) { throw RuntimeException(e) } - bot.playerManager.loadItemOrdered(event.guild, file, ResultHandler(null, event)) + bot.playerManager.loadItemOrdered(event.guild, file, ResultHandler(event)) } } } @@ -100,24 +98,12 @@ class Listener(private val bot: Bot) : ListenerAdapter() { bot.shutdown() } - private inner class ResultHandler(private val m: Message?, private val event: GuildVoiceUpdateEvent) : AudioLoadResultHandler { + private inner class ResultHandler(private val event: GuildVoiceUpdateEvent) : AudioLoadResultHandler { private fun loadSingle(track: AudioTrack) { val handler = event.guild.audioManager.sendingHandler as AudioHandler? handler!!.addTrack(QueuedTrack(track, event.member.user)) } - private fun loadPlaylist(playlist: AudioPlaylist, exclude: AudioTrack): Int { - val count = intArrayOf(0) - playlist.tracks.forEach(Consumer { track: AudioTrack -> - if (track != exclude) { - val handler = event.guild.audioManager.sendingHandler as AudioHandler? - handler!!.addTrack(QueuedTrack(track, event.member.user)) - count[0]++ - } - }) - return count[0] - } - override fun trackLoaded(track: AudioTrack) { loadSingle(track) } diff --git a/src/main/java/dev/cosgy/textToSpeak/commands/general/AboutCommand.kt b/src/main/java/dev/cosgy/textToSpeak/commands/general/AboutCommand.kt index 4a92aaa..8edbb83 100644 --- a/src/main/java/dev/cosgy/textToSpeak/commands/general/AboutCommand.kt +++ b/src/main/java/dev/cosgy/textToSpeak/commands/general/AboutCommand.kt @@ -114,7 +114,7 @@ ${jda.voiceChannels.size} ボイスチャンネル""", true) event.reply(builder.build()) } - fun getOauthLink(jda: JDA){ + private fun getOauthLink(jda: JDA){ if (oauthLink == null) { oauthLink = try { val info = jda.retrieveApplicationInfo().complete()