From 7797be389f3d0da06a0742fb794e3bb1a579a800 Mon Sep 17 00:00:00 2001 From: topi314 Date: Wed, 18 Sep 2024 22:52:34 +0200 Subject: [PATCH] update lavaplayer to 1.5.6 remove testbot since it doesn't compile anymore --- Testbot/build.gradle.kts | 27 ----- Testbot/readme.md | 35 ------ .../main/kotlin/lavalink/testbot/testbot.kt | 105 ------------------ Testbot/src/main/resources/logback.xml | 11 -- settings.gradle.kts | 4 +- 5 files changed, 1 insertion(+), 181 deletions(-) delete mode 100644 Testbot/build.gradle.kts delete mode 100644 Testbot/readme.md delete mode 100644 Testbot/src/main/kotlin/lavalink/testbot/testbot.kt delete mode 100644 Testbot/src/main/resources/logback.xml diff --git a/Testbot/build.gradle.kts b/Testbot/build.gradle.kts deleted file mode 100644 index 0c8b2ace5..000000000 --- a/Testbot/build.gradle.kts +++ /dev/null @@ -1,27 +0,0 @@ -plugins { - application - - kotlin("jvm") -} - -group = "lavalink" -version = "1.0" - -application { - mainClass.set("lavalink.testbot.TestbotKt") -} - -repositories { - mavenCentral() - jcenter() - maven("https://jitpack.io") -} - -dependencies { - compileOnly(libs.lavalink.client) - compileOnly(libs.logback) - compileOnly(libs.kotlin.stdlib.jdk8) - compileOnly(libs.jda) { - exclude(module = "opus-java") - } -} diff --git a/Testbot/readme.md b/Testbot/readme.md deleted file mode 100644 index ad87488b5..000000000 --- a/Testbot/readme.md +++ /dev/null @@ -1,35 +0,0 @@ -# Lavalink Testbot -This is a minimalistic example of a bot using Lavalink. This example is based upon Lavalink-Client for Java. - -https://github.com/freyacodes/lavalink-client - -This uses Lavaplayer to load tracks rather than initially loading tracks via Lavalink. Non-JVM (Java) bots will need -to query the `/loadtracks` endpoint. - - -## Running the test bot -This guide assumes the following: -* You have a Lavalink node already running -* You have a Discord bot and its token -* You have a shell in the same directory as this readme -* You have Java 11 or newer. Check with `java -version` - -Run this command. Gradle will download as needed, and will build and run the bot: -```bash -../gradlew run --args "YOUR_BOT_TOKEN ws://localhost:2333 youshallnotpass" -``` - -Replace token, host, and password as needed. - -Replace `../gradlew` with `../gradlew.bat` if on Windows. - - -## Using the test bot -Only one command is currently supported, and only the first or selected track of a playlist or search will be played. Example usages: -``` -;;play https://www.youtube.com/watch?v=cRh1-_pRDzo -;;play https://soundcloud.com/home-2001/resonance -;;play https://www.youtube.com/watch?v=t2D5HlKLh34&list=PLKUyqLlH6brkzzJgD6Gdriga4mdtCAMBJ -;;play ytsearch: John Coltrane Giant Steps -;;play https://www.youtube.com/watch?v=dQw4w9WgXcQ -``` \ No newline at end of file diff --git a/Testbot/src/main/kotlin/lavalink/testbot/testbot.kt b/Testbot/src/main/kotlin/lavalink/testbot/testbot.kt deleted file mode 100644 index 24144fbe4..000000000 --- a/Testbot/src/main/kotlin/lavalink/testbot/testbot.kt +++ /dev/null @@ -1,105 +0,0 @@ -package lavalink.testbot - -import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler -import com.sedmelluq.discord.lavaplayer.tools.FriendlyException -import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist -import com.sedmelluq.discord.lavaplayer.track.AudioTrack -import lavalink.client.io.jda.JdaLavalink -import net.dv8tion.jda.api.JDA -import net.dv8tion.jda.api.JDABuilder -import net.dv8tion.jda.api.entities.Member -import net.dv8tion.jda.api.entities.TextChannel -import net.dv8tion.jda.api.events.ReadyEvent -import net.dv8tion.jda.api.events.StatusChangeEvent -import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent -import net.dv8tion.jda.api.hooks.ListenerAdapter -import net.dv8tion.jda.api.requests.GatewayIntent -import net.dv8tion.jda.api.utils.cache.CacheFlag.* -import org.slf4j.Logger -import org.slf4j.LoggerFactory -import java.net.URI - -private val log: Logger = LoggerFactory.getLogger("Testbot") -private lateinit var jda: JDA -private val lavalink = JdaLavalink(1) { _ -> jda } -lateinit var host: String -lateinit var password: String - -fun main(args: Array) { - if (args.size < 3) { - throw IllegalArgumentException("Expected 3 arguments. Please refer to the readme.") - } - - val token = args[0] - host = args[1] - password = args[2] - - jda = JDABuilder.createDefault(token, - GatewayIntent.GUILD_MESSAGES, - GatewayIntent.GUILD_VOICE_STATES) - .disableCache(CLIENT_STATUS, ACTIVITY, CLIENT_STATUS, EMOTE, MEMBER_OVERRIDES) - .addEventListeners(Listener, lavalink) - .setVoiceDispatchInterceptor(lavalink.voiceInterceptor) - .build() -} - -object Listener : ListenerAdapter() { - override fun onStatusChange(event: StatusChangeEvent) { - log.info("{} -> {}", event.oldStatus, event.newStatus) - } - - override fun onReady(event: ReadyEvent) { - lavalink.setUserId(jda.selfUser.id) - lavalink.addNode(URI(host), password) - } - - override fun onGuildMessageReceived(event: GuildMessageReceivedEvent) { - val member = event.member ?: return - if (member.user.isBot) return - - try { - play(event.channel, member, event.message.contentRaw) - } catch (e: Exception) { - event.channel.sendMessage(e.message ?: e.toString()).queue() - } - } -} - -fun play(channel: TextChannel, member: Member, message: String) { - if (message.startsWith(";;play ")) { - val vc = member.voiceState?.channel - if (vc == null) { - channel.sendMessage("You must be in a voice channel").queue() - return - } - - val link = lavalink.getLink(channel.guild) - link.connect(vc) - - val track = message.drop(";;play ".length).trim() - link.node?.restClient?.loadItem(track, object : AudioLoadResultHandler { - override fun loadFailed(e: FriendlyException) { - channel.sendMessage(e.message ?: e.toString()).queue() - } - - override fun trackLoaded(track: AudioTrack) { - channel.sendMessage("Playing `${track.info.title}`").queue() - link.player.playTrack(track) - } - - override fun noMatches() { - channel.sendMessage("No matches").queue() - } - - override fun playlistLoaded(playlist: AudioPlaylist) { - val loaded = playlist.selectedTrack ?: playlist.tracks.firstOrNull() - if (loaded == null) { - channel.sendMessage("Empty playlist").queue() - return - } - channel.sendMessage("Playing `${loaded.info.title}` from list `${playlist.name}`").queue() - link.player.playTrack(loaded) - } - }) - } -} \ No newline at end of file diff --git a/Testbot/src/main/resources/logback.xml b/Testbot/src/main/resources/logback.xml deleted file mode 100644 index 4bd2e3760..000000000 --- a/Testbot/src/main/resources/logback.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index f6ac1ff7a..8f1142574 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,9 +2,7 @@ rootProject.name = "Lavalink-Parent" include(":Lavalink-Server") include(":protocol") -include(":Testbot") include(":plugin-api") -include("plugin-api") project(":Lavalink-Server").projectDir = file("$rootDir/LavalinkServer") @@ -38,7 +36,7 @@ fun VersionCatalogBuilder.spring() { } fun VersionCatalogBuilder.voice() { - version("lavaplayer", "1.5.4") + version("lavaplayer", "1.5.6") library("lavaplayer", "dev.arbjerg", "lavaplayer").versionRef("lavaplayer") library("lavaplayer-ip-rotator", "dev.arbjerg", "lavaplayer-ext-youtube-rotator").versionRef("lavaplayer")