diff --git a/.gitignore b/.gitignore
index 0cba8fa..49298b8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,5 @@
### CUSTOM ###
/run/
-/data/
-data/
/.idea/
diff --git a/README.md b/README.md
index 2d87a9b..9be1942 100644
--- a/README.md
+++ b/README.md
@@ -4,29 +4,33 @@
A Discord music bot, written in Kotlin using the kord library.
+[](https://gitlab.com/moonleay/botendo/-/releases)
+[](https://gitlab.com/moonleay/botendo/-/commits/master)
+[](https://gitlab.com/moonleay/botendo/-/commits/master)
+
## Contributors
-[](https://gitlab.com/moonleay)
+
+

+
## Special Thanks to
- HopeBaron for helping me a lot
-## Issues
+## Known issues
-- Report issues to issues@moonleay.net or message @moonleay on Discord
+- None (currently). Report issues to issues@moonleay.net or moonleay#7441
## Commands & Features
- Commands
- - info -- Show basic infos about the bot
- - play -- Play a song and or add it to queue
- - upsert -- Play a song next up
- - stop -- Stop playing a song and leave the vc
- - skip -- Skip to the next song
- - queue -- Show what songs are next up
- - nowplaying -- Show what is currently playing
- - seek -- Seek to a specific time in the song
+ - info -- Show basic infos about the bot
+ - play -- Play a song
+ - stop -- Stop playing a song and leave the vc
+ - skip -- Skip to the next song
+ - queue -- Show what songs are next up
+ - nowplaying -- Show what is currently playing
- Features
- Button Controller -- You can control the currently playing music using buttons.
@@ -60,3 +64,9 @@ A Discord music bot, written in Kotlin using the kord library.
Install IntellJ and import the project from git.
Done.
+
+## Docker commands 4 me
+
+- docker run -it -m 2g -v/home/limited_dev/Documents/Code/Botendo/run/data/:/data/:rw limiteddev/botendo:x.x.x
+- docker build -t limiteddev/botendo:x.x.x .
+- docker push limiteddev/botendo:x.x.x
diff --git a/build.gradle.kts b/build.gradle.kts
index f31be78..dba3b59 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -14,6 +14,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
+ *
*/
import org.jetbrains.gradle.ext.ProjectSettings
@@ -29,15 +30,14 @@ plugins {
//Botendo version 6
val ownerID = 372703841151614976L
-group = "net.moonleay.botendo"
+group = "de.limited_dev.botendo"
version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" }
?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" }
- ?: "6.5.5"
+ ?: "6.3.3"
-val kordext_ver = "1.7.1-SNAPSHOT"
-val lavakord_ver = "6.0.0"
-val coroutines_ver = "1.7.3"
-val slf4j_ver = "2.0.9"
+val kordver = "1.5.6"
+val lavaver = "4.0.0"
+val coroutinesver = "1.1.0"
val mavenArtifact = "Botendo"
project.base.archivesName.set(mavenArtifact)
@@ -70,14 +70,6 @@ repositories {
}
}
}
- maven {
- name = "sonatype"
- url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots")
- }
- maven {
- name = "sonatype 2"
- url = uri("https://oss.sonatype.org/content/repositories/snapshots")
- }
}
val shadow by configurations.getting
@@ -86,15 +78,15 @@ implementation.extendsFrom(shadow)
dependencies {
//Discord
- shadow("com.kotlindiscord.kord.extensions:kord-extensions:$kordext_ver")
- shadow("dev.schlaubi.lavakord:kord:$lavakord_ver")
+ shadow("com.kotlindiscord.kord.extensions:kord-extensions:$kordver")
+ shadow("dev.schlaubi.lavakord:kord:$lavaver")
//Util
- shadow("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_ver")
+ shadow("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesver")
//Logging
- shadow("org.slf4j:slf4j-api:$slf4j_ver")
- shadow("org.slf4j:slf4j-simple:$slf4j_ver")
+ shadow("org.slf4j:slf4j-api:2.0.3")
+ shadow("org.slf4j:slf4j-simple:2.0.3")
}
@@ -104,9 +96,9 @@ val templateDest = project.buildDir.resolve("generated/templates")
val templateProps = mapOf(
"version" to project.version as String,
"ownerID" to ownerID,
- "kordversion" to kordext_ver,
- "lavaversion" to lavakord_ver,
- "coroutinesversion" to coroutines_ver
+ "kordversion" to kordver,
+ "lavaversion" to lavaver,
+ "coroutinesversion" to coroutinesver
)
@@ -123,7 +115,7 @@ tasks {
withType {
manifest {
- attributes["Main-Class"] = "net.moonleay.botendo.MainKt"
+ attributes["Main-Class"] = "de.limited_dev.botendo.MainKt"
}
// To add all of the dependencies
from(sourceSets.main.get().output)
diff --git a/gradle.properties b/gradle.properties
index b2ec467..6ff0886 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -15,4 +15,5 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
+#
kotlin.code.style=official
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index d64cd49..249e583 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 22d4fe0..85958c5 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -15,11 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
-
+#
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
-networkTimeout=10000
-validateDistributionUrl=true
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index 3052411..10c8ca9 100755
--- a/gradlew
+++ b/gradlew
@@ -17,6 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
+#
##############################################################################
#
@@ -57,7 +58,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
-# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -82,11 +83,13 @@ do
esac
done
-# This is normally unused
-# shellcheck disable=SC2034
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
+
+APP_NAME="Gradle"
APP_BASE_NAME=${0##*/}
-# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
-APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -133,29 +136,22 @@ location of your Java installation."
fi
else
JAVACMD=java
- if ! command -v java >/dev/null 2>&1
- then
- die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
- fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
- # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
- # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
- # shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -200,15 +196,11 @@ if "$cygwin" || "$msys" ; then
done
fi
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
-
-# Collect all arguments for the java command:
-# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
-# and any embedded shellness will be escaped.
-# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
-# treated as '${Hostname}' itself on the command line.
+# Collect all arguments for the java command;
+# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
+# shell script including quotes and variable substitutions, so put them in
+# double quotes to make sure that they get re-expanded; and
+# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
@@ -216,12 +208,6 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"
-# Stop when "xargs" is not available.
-if ! command -v xargs >/dev/null 2>&1
-then
- die "xargs is not available"
-fi
-
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
diff --git a/gradlew.bat b/gradlew.bat
index 93e3f59..107acd3 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -14,7 +14,7 @@
@rem limitations under the License.
@rem
-@if "%DEBUG%"=="" @echo off
+@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -25,8 +25,7 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
-if "%DIRNAME%"=="" set DIRNAME=.
-@rem This is normally unused
+if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@@ -41,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if %ERRORLEVEL% equ 0 goto execute
+if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -76,15 +75,13 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end
@rem End local scope for the variables with windows NT shell
-if %ERRORLEVEL% equ 0 goto mainEnd
+if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
-set EXIT_CODE=%ERRORLEVEL%
-if %EXIT_CODE% equ 0 set EXIT_CODE=1
-if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
-exit /b %EXIT_CODE%
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 3934113..7a3ef44 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -1,19 +1,20 @@
/*
- * Botendo
- * Copyright (C) 2023 moonleay
+ * Botendo
+ * Copyright (C) 2023 limited_dev
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
*/
rootProject.name = "Botendo"
diff --git a/src/main/kotlin/net/moonleay/botendo/Bot.kt b/src/main/kotlin/de/limited_dev/botendo/Bot.kt
similarity index 53%
rename from src/main/kotlin/net/moonleay/botendo/Bot.kt
rename to src/main/kotlin/de/limited_dev/botendo/Bot.kt
index ca3bb19..1e3ba7a 100644
--- a/src/main/kotlin/net/moonleay/botendo/Bot.kt
+++ b/src/main/kotlin/de/limited_dev/botendo/Bot.kt
@@ -14,31 +14,24 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
+ *
*/
-package net.moonleay.botendo
+package de.limited_dev.botendo
import com.kotlindiscord.kord.extensions.ExtensibleBot
+import de.limited_dev.botendo.buttons.ButtonManager
+import de.limited_dev.botendo.data.CredentialManager
+import de.limited_dev.botendo.extensions.music.*
+import de.limited_dev.botendo.extensions.util.InfoExtension
+import de.limited_dev.botendo.util.Logger
+import de.limited_dev.botendo.util.MessageUtil
import dev.kord.common.Color
-import dev.kord.common.entity.Snowflake
-import dev.kord.core.behavior.getChannelOf
import dev.kord.core.behavior.interaction.response.respond
-import dev.kord.core.entity.channel.VoiceChannel
import dev.kord.core.event.interaction.ButtonInteractionCreateEvent
-import dev.kord.core.event.user.VoiceStateUpdateEvent
import dev.kord.core.on
-import dev.kord.rest.builder.message.embed
import dev.schlaubi.lavakord.LavaKord
-import dev.schlaubi.lavakord.audio.Link
-import dev.schlaubi.lavakord.kord.getLink
import dev.schlaubi.lavakord.kord.lavakord
-import kotlinx.coroutines.flow.count
-import net.moonleay.botendo.data.CredentialManager
-import net.moonleay.botendo.extensions.music.*
-import net.moonleay.botendo.extensions.music.components.MusicManager
-import net.moonleay.botendo.extensions.util.InfoExtension
-import net.moonleay.botendo.util.Logger
-import net.moonleay.botendo.util.MessageUtil
object Bot {
//The kord object gets set at app launch
@@ -70,12 +63,10 @@ object Bot {
add(::SkipExtension)
add(::NowPlayingExtension)
add(::QueueExtension)
- add(::UpsertExtension)
- add(::SeekExtension)
}
this.presence {
- this.streaming("music", "https://twitch.tv/moonleaytv")
+ this.streaming("music", "https://twitch.tv/limited_dev")
}
}
@@ -91,53 +82,24 @@ object Bot {
val response = inter.deferPublicResponse()
val u = inter.user
val g = this.interaction.getOriginalInteractionResponse().getGuild()
- for (b in net.moonleay.botendo.buttons.ButtonManager.buttons) {
+ for (b in ButtonManager.buttons) {
if (b.id != inter.componentId)
continue
b.onInteraction(response, g, u)
return@on
}
- // Button not found
response.respond {
- this.embed {
- this.color = Color(0xE0311A)
- this.title = "Error"
- this.description = "Could not find button with id \"${inter.componentId}\".\nPlease report this."
- this.footer {
- this.text = MessageUtil.getFooter(u)
- }
- }
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "Error",
+ "Could not find button with id \"${inter.componentId}\".\nPlease report this.",
+ u.asUser().username + "#" + u.asUser().discriminator
+ )
+ )
}
}
- // Allow the bot to leave the VC if there are no users in the VC
- bot.kordRef.on {
- if (this.state.userId == bot.kordRef.selfId) {
- // Ignore self
- return@on
- }
- val g = this.state.getGuild().asGuild()
- val link = lava.getLink(g.id)
- if (link.state != Link.State.CONNECTED) {
- // Ignore if not connected
- return@on
- }
- val myChannel = link.lastChannelId!!
- if (g.getChannelOrNull(Snowflake(myChannel)) == null) {
- // Ignore if channel cannot be found
- return@on
- }
- val ch = g.getChannelOf(Snowflake(myChannel))
- if (ch.voiceStates.count() > 1) {
- // Ignore if there are other users in the channel
- return@on
- }
- // Stop playing if there are no users in the channel
- val pl = MusicManager.getMusicManager(g)!!.pl
- pl.stopTrack()
- link.destroy()
- }
-
//Start the bot
bot.start()
}
diff --git a/src/main/kotlin/net/moonleay/botendo/Main.kt b/src/main/kotlin/de/limited_dev/botendo/Main.kt
similarity index 72%
rename from src/main/kotlin/net/moonleay/botendo/Main.kt
rename to src/main/kotlin/de/limited_dev/botendo/Main.kt
index 0555150..428f277 100644
--- a/src/main/kotlin/net/moonleay/botendo/Main.kt
+++ b/src/main/kotlin/de/limited_dev/botendo/Main.kt
@@ -14,15 +14,16 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
+ *
*/
-package net.moonleay.botendo
+package de.limited_dev.botendo
-import net.moonleay.botendo.util.Logger
+import de.limited_dev.botendo.build.BuildConstants
///Show the splash and launch the Bot
-suspend fun main(args: Array) {
+suspend fun main() {
println(
"M#\"\"\"\"\"\"\"'M dP dP \n" +
"## mmmm. `M 88 88 \n" +
@@ -33,10 +34,6 @@ suspend fun main(args: Array) {
"M#########M \n" +
" "
)
- println("Bot v.${net.moonleay.botendo.build.BuildConstants.version}, Kord Extensions v.${net.moonleay.botendo.build.BuildConstants.kordVersion}, LavaKord v.${net.moonleay.botendo.build.BuildConstants.lavaVersion}, Coroutines v.${net.moonleay.botendo.build.BuildConstants.coroutinesVersion}")
- if(args.isEmpty() || args[0] != "--debug") {
- Logger.out("Waiting 10 seconds for Lavalink to start...")
- Thread.sleep(10000)
- }
+ println("Bot v.${BuildConstants.version}, Kord Extensions v.${BuildConstants.kordVersion}, LavaKord v.${BuildConstants.lavaVersion}, Coroutines v.${BuildConstants.coroutinesVersion}")
Bot.start()
}
diff --git a/src/main/kotlin/net/moonleay/botendo/buttons/Button.kt b/src/main/kotlin/de/limited_dev/botendo/buttons/Button.kt
similarity index 96%
rename from src/main/kotlin/net/moonleay/botendo/buttons/Button.kt
rename to src/main/kotlin/de/limited_dev/botendo/buttons/Button.kt
index e0c10ef..ea63f82 100644
--- a/src/main/kotlin/net/moonleay/botendo/buttons/Button.kt
+++ b/src/main/kotlin/de/limited_dev/botendo/buttons/Button.kt
@@ -14,9 +14,10 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
+ *
*/
-package net.moonleay.botendo.buttons
+package de.limited_dev.botendo.buttons
import dev.kord.core.behavior.interaction.response.DeferredPublicMessageInteractionResponseBehavior
import dev.kord.core.entity.Guild
diff --git a/src/main/kotlin/net/moonleay/botendo/buttons/ButtonManager.kt b/src/main/kotlin/de/limited_dev/botendo/buttons/ButtonManager.kt
similarity index 76%
rename from src/main/kotlin/net/moonleay/botendo/buttons/ButtonManager.kt
rename to src/main/kotlin/de/limited_dev/botendo/buttons/ButtonManager.kt
index 3ab406e..618676b 100644
--- a/src/main/kotlin/net/moonleay/botendo/buttons/ButtonManager.kt
+++ b/src/main/kotlin/de/limited_dev/botendo/buttons/ButtonManager.kt
@@ -14,18 +14,13 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
+ *
*/
-package net.moonleay.botendo.buttons
+package de.limited_dev.botendo.buttons
-import net.moonleay.botendo.buttons.music.*
+import de.limited_dev.botendo.buttons.music.*
object ButtonManager {
- val buttons = listOf(
- RepeatButton(),
- PauseButton(),
- SkipButton(),
- QueueButton(),
- StopButton()
- )
+ val buttons = listOf(RepeatButton(), PauseButton(), SkipButton(), QueueButton(), StopButton())
}
diff --git a/src/main/kotlin/de/limited_dev/botendo/buttons/music/PauseButton.kt b/src/main/kotlin/de/limited_dev/botendo/buttons/music/PauseButton.kt
new file mode 100644
index 0000000..df894b0
--- /dev/null
+++ b/src/main/kotlin/de/limited_dev/botendo/buttons/music/PauseButton.kt
@@ -0,0 +1,105 @@
+/*
+ * Botendo
+ * Copyright (C) 2023 moonleay
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package de.limited_dev.botendo.buttons.music
+
+import de.limited_dev.botendo.Bot
+import de.limited_dev.botendo.buttons.Button
+import de.limited_dev.botendo.extensions.music.components.MusicManager
+import de.limited_dev.botendo.util.ButtonUtil
+import de.limited_dev.botendo.util.MessageUtil
+import dev.kord.common.Color
+import dev.kord.core.behavior.interaction.response.DeferredPublicMessageInteractionResponseBehavior
+import dev.kord.core.behavior.interaction.response.respond
+import dev.kord.core.entity.Guild
+import dev.kord.core.entity.User
+import dev.kord.rest.builder.message.modify.actionRow
+import dev.schlaubi.lavakord.audio.Link
+
+class PauseButton : Button("btn.music.pause") {
+ override suspend fun onInteraction(
+ response: DeferredPublicMessageInteractionResponseBehavior,
+ guild: Guild,
+ user: User
+ ) {
+ val guildId = guild.id
+ val link = Bot.lava.getLink(guildId.toString())
+ val player = link.player
+ val voiceState = user.asMember(guildId).getVoiceStateOrNull()
+ if (voiceState == null) {
+ response.respond {
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "You are not connected to a VC",
+ "Please connect to a VC",
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
+ }
+ return
+ }
+
+ val channelId = voiceState.channelId
+ if (link.state == Link.State.NOT_CONNECTED) {
+ response.respond {
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "Not connected",
+ "I'm not in a VC and therefore, I am not playing anything.",
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
+ }
+ return
+ } else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) {
+ response.respond {
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "You are not in my VC",
+ "We are not in the same VC and therefore, you cannot control the music",
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
+ }
+ return
+ }
+
+ player.pause(!player.paused)
+
+ val gts = MusicManager.getGuildTrackScheduler(guild, player)
+ response.respond {
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0x52E01A),
+ if (player.paused) "I paused" else "I'm continuing",
+ if (player.paused) "I paused the song" else "I'm continuing to play the song.",
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
+
+
+ this.actionRow {
+ this.components.addAll(ButtonUtil.getMusicControllerButtons(player.paused, gts.repeating).components)
+ }
+ }
+ }
+}
diff --git a/src/main/kotlin/net/moonleay/botendo/buttons/music/QueueButton.kt b/src/main/kotlin/de/limited_dev/botendo/buttons/music/QueueButton.kt
similarity index 50%
rename from src/main/kotlin/net/moonleay/botendo/buttons/music/QueueButton.kt
rename to src/main/kotlin/de/limited_dev/botendo/buttons/music/QueueButton.kt
index c786818..ef6d94b 100644
--- a/src/main/kotlin/net/moonleay/botendo/buttons/music/QueueButton.kt
+++ b/src/main/kotlin/de/limited_dev/botendo/buttons/music/QueueButton.kt
@@ -14,83 +14,83 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
+ *
*/
-package net.moonleay.botendo.buttons.music
+package de.limited_dev.botendo.buttons.music
+import de.limited_dev.botendo.Bot
+import de.limited_dev.botendo.buttons.Button
+import de.limited_dev.botendo.extensions.music.components.MusicManager
+import de.limited_dev.botendo.util.ButtonUtil
+import de.limited_dev.botendo.util.MessageUtil
+import de.limited_dev.botendo.util.TimeUtil
import dev.kord.common.Color
import dev.kord.core.behavior.interaction.response.DeferredPublicMessageInteractionResponseBehavior
import dev.kord.core.behavior.interaction.response.respond
import dev.kord.core.entity.Guild
import dev.kord.core.entity.User
-import dev.kord.rest.builder.component.ActionRowBuilder
-import dev.kord.rest.builder.message.actionRow
-import dev.kord.rest.builder.message.embed
+import dev.kord.rest.builder.message.modify.actionRow
import dev.schlaubi.lavakord.audio.Link
-import net.moonleay.botendo.extensions.music.components.MusicManager
-import net.moonleay.botendo.util.ButtonUtil
-import net.moonleay.botendo.util.MessageUtil
-import net.moonleay.botendo.util.TimeUtil
-class QueueButton : net.moonleay.botendo.buttons.Button("btn.music.queue") {
+class QueueButton : Button("btn.music.queue") {
override suspend fun onInteraction(
response: DeferredPublicMessageInteractionResponseBehavior,
guild: Guild,
user: User
) {
val guildId = guild.id
- val link = net.moonleay.botendo.Bot.lava.getLink(guildId.toString())
+ val link = Bot.lava.getLink(guildId.toString())
val player = link.player
if (link.state == Link.State.NOT_CONNECTED) {
response.respond {
- this.embed {
- this.color = Color(0xE0311A)
- this.title = "Not connected"
- this.description = "I'm not in a VC and therefore, I am not playing anything."
- this.footer {
- this.text = MessageUtil.getFooter(user)
- }
- }
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "Not connected",
+ "I'm not in a VC and therefore, I am not playing anything.",
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
}
return
}
- if (player.playingTrack == null) {
+ val track = player.playingTrack
+ if (track == null) {
response.respond {
- this.embed {
- this.color = Color(0xE0311A)
- this.title = "Not playing"
- this.description = "I'm not playing anything currently"
- this.footer {
- this.text = MessageUtil.getFooter(user)
- }
- }
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "Not playing",
+ "I'm not playing anything currently", user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
}
return
}
- val track = player.playingTrack!!.info
val gts = MusicManager.getGuildTrackScheduler(guild.asGuild(), player)
val q = gts.getQueue()
var desc =
- """${"**" + track.title + " - " + TimeUtil.getTimeFormatedShortend(track.length)} (${track.author})**""" + "\n"
+ """${"**" + track.title + " - " + TimeUtil.getTimeFormatedShortend(track.length.inWholeMilliseconds)} (${track.author})**""" + "\n"
for ((i, tr) in q.withIndex()) {
if (i >= 14)
continue
desc += tr.info.title + " - " + TimeUtil.getTimeFormatedShortend(tr.info.length) + " (" + tr.info.author + ")\n"
}
response.respond {
- this.embed {
- this.color = Color(0x52E01A)
- this.title = "Queue"
- this.description = desc
- this.footer {
- this.text = MessageUtil.getFooter(user)
- }
- }
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0x52E01A),
+ "Queue",
+ desc,
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
- this.actionRow(fun ActionRowBuilder.() {
- components.addAll(ButtonUtil.getMusicControllerButtons(player.paused, gts.repeating).components)
- })
+ this.actionRow {
+ this.components.addAll(ButtonUtil.getMusicControllerButtons(player.paused, gts.repeating).components)
+ }
}
}
}
diff --git a/src/main/kotlin/de/limited_dev/botendo/buttons/music/RepeatButton.kt b/src/main/kotlin/de/limited_dev/botendo/buttons/music/RepeatButton.kt
new file mode 100644
index 0000000..92c3ae2
--- /dev/null
+++ b/src/main/kotlin/de/limited_dev/botendo/buttons/music/RepeatButton.kt
@@ -0,0 +1,104 @@
+/*
+ * Botendo
+ * Copyright (C) 2023 moonleay
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package de.limited_dev.botendo.buttons.music
+
+import de.limited_dev.botendo.Bot
+import de.limited_dev.botendo.buttons.Button
+import de.limited_dev.botendo.extensions.music.components.MusicManager
+import de.limited_dev.botendo.util.ButtonUtil
+import de.limited_dev.botendo.util.MessageUtil
+import dev.kord.common.Color
+import dev.kord.core.behavior.interaction.response.DeferredPublicMessageInteractionResponseBehavior
+import dev.kord.core.behavior.interaction.response.respond
+import dev.kord.core.entity.Guild
+import dev.kord.core.entity.User
+import dev.kord.rest.builder.message.modify.actionRow
+import dev.schlaubi.lavakord.audio.Link
+
+class RepeatButton : Button("btn.music.repeat") {
+ override suspend fun onInteraction(
+ response: DeferredPublicMessageInteractionResponseBehavior,
+ guild: Guild,
+ user: User
+ ) {
+ val guildId = guild.id
+ val link = Bot.lava.getLink(guildId.toString())
+ val player = link.player
+ val voiceState = user.asMember(guildId).getVoiceStateOrNull()
+ if (voiceState == null) {
+ response.respond {
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "You are not connected to a VC",
+ "Please connect to a VC",
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
+ }
+ return
+ }
+
+ val channelId = voiceState.channelId
+ if (link.state == Link.State.NOT_CONNECTED) {
+ response.respond {
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "Not connected",
+ "I'm not in a VC and therefore, I am not playing anything.",
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
+ }
+ return
+ } else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) {
+ response.respond {
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "You are not in my VC",
+ "We are not in the same VC and therefore, you cannot control the music",
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
+ }
+ return
+ }
+
+ val gts = MusicManager.getGuildTrackScheduler(guild, player)
+ gts.repeating = !gts.repeating
+ response.respond {
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0x52E01A),
+ if (gts.repeating) "Now Repeating" else "Now Continuing",
+ if (gts.repeating) "The current track will now loop" else "The next track will play when this song finishes",
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
+
+
+ this.actionRow {
+ this.components.addAll(ButtonUtil.getMusicControllerButtons(player.paused, gts.repeating).components)
+ }
+ }
+ }
+}
diff --git a/src/main/kotlin/de/limited_dev/botendo/buttons/music/SkipButton.kt b/src/main/kotlin/de/limited_dev/botendo/buttons/music/SkipButton.kt
new file mode 100644
index 0000000..547fc05
--- /dev/null
+++ b/src/main/kotlin/de/limited_dev/botendo/buttons/music/SkipButton.kt
@@ -0,0 +1,147 @@
+/*
+ * Botendo
+ * Copyright (C) 2023 moonleay
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package de.limited_dev.botendo.buttons.music
+
+import de.limited_dev.botendo.Bot
+import de.limited_dev.botendo.buttons.Button
+import de.limited_dev.botendo.extensions.music.components.MusicManager
+import de.limited_dev.botendo.util.ButtonUtil
+import de.limited_dev.botendo.util.MessageUtil
+import de.limited_dev.botendo.util.TimeUtil
+import de.limited_dev.botendo.util.UrlUtil
+import dev.kord.common.Color
+import dev.kord.core.behavior.interaction.response.DeferredPublicMessageInteractionResponseBehavior
+import dev.kord.core.behavior.interaction.response.respond
+import dev.kord.core.entity.Guild
+import dev.kord.core.entity.User
+import dev.kord.rest.builder.message.modify.actionRow
+import dev.schlaubi.lavakord.audio.Link
+
+class SkipButton : Button("btn.music.skip") {
+ override suspend fun onInteraction(
+ response: DeferredPublicMessageInteractionResponseBehavior,
+ guild: Guild,
+ user: User
+ ) {
+ val guildId = guild.id
+ val link = Bot.lava.getLink(guildId.toString())
+ val player = link.player
+ val voiceState = user.asMember(guildId).getVoiceStateOrNull()
+ if (voiceState == null) {
+ response.respond {
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "You are not connected to a VC",
+ "Please connect to a VC",
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
+ }
+ return
+ }
+
+ val channelId = voiceState.channelId
+ if (link.state == Link.State.NOT_CONNECTED) {
+ response.respond {
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "Not connected",
+ "I'm not in a VC and therefore, I am not playing anything.",
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
+ }
+ return
+ } else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) {
+ response.respond {
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "You are not in my VC",
+ "We are not in the same VC and therefore, you cannot control the music",
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
+ }
+ return
+ }
+ var track = player.playingTrack
+ if (track == null) {
+ response.respond {
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "Not playing",
+ "I'm not playing anything currently", user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
+ }
+ return
+ }
+ val gts = MusicManager.getGuildTrackScheduler(guild.asGuild(), player)
+ if (!gts.isEmpty()) {
+ track = gts.getHead().toTrack()
+ gts.playNext(link)
+ response.respond {
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbedWithImage(
+ Color(0x52E01A),
+ "Skipped song; now playing",
+ "**${track.title}**\n*Now Playing*\nby ${track.author} :: ${
+ TimeUtil.getTimeFormatedRaw(
+ track.length.inWholeMilliseconds
+ )
+ }\n" +
+ ">>>${track.uri}",
+ "https://img.youtube.com/vi/" + UrlUtil.getYtThumbnailUrl(track.uri!!) + "/maxresdefault.jpg",
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
+
+ this.actionRow {
+ this.components.addAll(
+ ButtonUtil.getMusicControllerButtons(
+ player.paused,
+ gts.repeating
+ ).components
+ )
+ }
+ }
+ return
+ }
+ player.stopTrack()
+
+ response.respond {
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0x52E01A),
+ "Skipped song; now playing",
+ "Nothing",
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
+ this.actionRow {
+ this.components.addAll(ButtonUtil.getMusicControllerButtons(player.paused, gts.repeating).components)
+ }
+ }
+ }
+}
diff --git a/src/main/kotlin/net/moonleay/botendo/buttons/music/StopButton.kt b/src/main/kotlin/de/limited_dev/botendo/buttons/music/StopButton.kt
similarity index 51%
rename from src/main/kotlin/net/moonleay/botendo/buttons/music/StopButton.kt
rename to src/main/kotlin/de/limited_dev/botendo/buttons/music/StopButton.kt
index eb1a213..a6a1697 100644
--- a/src/main/kotlin/net/moonleay/botendo/buttons/music/StopButton.kt
+++ b/src/main/kotlin/de/limited_dev/botendo/buttons/music/StopButton.kt
@@ -14,40 +14,42 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
+ *
*/
-package net.moonleay.botendo.buttons.music
+package de.limited_dev.botendo.buttons.music
+import de.limited_dev.botendo.Bot
+import de.limited_dev.botendo.buttons.Button
+import de.limited_dev.botendo.extensions.music.components.MusicManager
+import de.limited_dev.botendo.util.MessageUtil
import dev.kord.common.Color
import dev.kord.core.behavior.interaction.response.DeferredPublicMessageInteractionResponseBehavior
import dev.kord.core.behavior.interaction.response.respond
import dev.kord.core.entity.Guild
import dev.kord.core.entity.User
-import dev.kord.rest.builder.message.embed
import dev.schlaubi.lavakord.audio.Link
-import net.moonleay.botendo.extensions.music.components.MusicManager
-import net.moonleay.botendo.util.MessageUtil
-class StopButton : net.moonleay.botendo.buttons.Button("btn.music.stop") {
+class StopButton : Button("btn.music.stop") {
override suspend fun onInteraction(
response: DeferredPublicMessageInteractionResponseBehavior,
guild: Guild,
user: User
) {
val guildId = guild.id
- val link = net.moonleay.botendo.Bot.lava.getLink(guildId.toString())
+ val link = Bot.lava.getLink(guildId.toString())
val player = link.player
val voiceState = user.asMember(guildId).getVoiceStateOrNull()
if (voiceState == null) {
response.respond {
- this.embed {
- this.color = Color(0xE0311A)
- this.title = "You are not connected to a VC"
- this.description = "Please connect to a VC"
- this.footer {
- this.text = MessageUtil.getFooter(user)
- }
- }
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "You are not connected to a VC",
+ "Please connect to a VC",
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
}
return
}
@@ -55,26 +57,26 @@ class StopButton : net.moonleay.botendo.buttons.Button("btn.music.stop") {
val channelId = voiceState.channelId
if (link.state == Link.State.NOT_CONNECTED) {
response.respond {
- this.embed {
- this.color = Color(0xE0311A)
- this.title = "Not connected"
- this.description = "I'm not in a VC and therefore, I am not playing anything."
- this.footer {
- this.text = MessageUtil.getFooter(user)
- }
- }
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "Not connected",
+ "I'm not in a VC and therefore, I am not playing anything.",
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
}
return
} else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) {
response.respond {
- this.embed {
- this.color = Color(0xE0311A)
- this.title = "You are not in my VC"
- this.description = "We are not in the same VC and therefore, you cannot control the music"
- this.footer {
- this.text = MessageUtil.getFooter(user)
- }
- }
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "You are not in my VC",
+ "We are not in the same VC and therefore, you cannot control the music",
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
}
return
}
@@ -83,14 +85,14 @@ class StopButton : net.moonleay.botendo.buttons.Button("btn.music.stop") {
link.destroy()
MusicManager.getGuildTrackScheduler(guild.asGuild(), player).clear()
response.respond {
- this.embed {
- this.color = Color(0x52E01A)
- this.title = "I stopped and left"
- this.description = "just like your girlfriend"
- this.footer {
- this.text = MessageUtil.getFooter(user)
- }
- }
+ this.embeds = mutableListOf(
+ MessageUtil.getEmbed(
+ Color(0x52E01A),
+ "I stopped and left",
+ "just like your girlfriend",
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
}
}
}
diff --git a/src/main/kotlin/net/moonleay/botendo/data/CredentialManager.kt b/src/main/kotlin/de/limited_dev/botendo/data/CredentialManager.kt
similarity index 98%
rename from src/main/kotlin/net/moonleay/botendo/data/CredentialManager.kt
rename to src/main/kotlin/de/limited_dev/botendo/data/CredentialManager.kt
index 23ca661..78868fa 100644
--- a/src/main/kotlin/net/moonleay/botendo/data/CredentialManager.kt
+++ b/src/main/kotlin/de/limited_dev/botendo/data/CredentialManager.kt
@@ -14,9 +14,10 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
+ *
*/
-package net.moonleay.botendo.data
+package de.limited_dev.botendo.data
import java.io.*
import java.util.*
diff --git a/src/main/kotlin/de/limited_dev/botendo/extensions/music/NowPlayingExtension.kt b/src/main/kotlin/de/limited_dev/botendo/extensions/music/NowPlayingExtension.kt
new file mode 100644
index 0000000..5788901
--- /dev/null
+++ b/src/main/kotlin/de/limited_dev/botendo/extensions/music/NowPlayingExtension.kt
@@ -0,0 +1,99 @@
+/*
+ * Botendo
+ * Copyright (C) 2023 moonleay
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package de.limited_dev.botendo.extensions.music
+
+import com.kotlindiscord.kord.extensions.extensions.Extension
+import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
+import com.kotlindiscord.kord.extensions.types.respond
+import de.limited_dev.botendo.Bot
+import de.limited_dev.botendo.extensions.music.components.MusicManager
+import de.limited_dev.botendo.util.ButtonUtil
+import de.limited_dev.botendo.util.MessageUtil
+import de.limited_dev.botendo.util.TimeUtil
+import de.limited_dev.botendo.util.UrlUtil
+import dev.kord.common.Color
+import dev.kord.rest.builder.message.create.actionRow
+import dev.schlaubi.lavakord.audio.Link
+import dev.schlaubi.lavakord.kord.getLink
+
+class NowPlayingExtension : Extension() {
+ override val name = "nowplaying"
+ override suspend fun setup() {
+ publicSlashCommand {
+ name = "nowplaying"
+ description = "Show what's currently playing"
+ this.action {
+ val guildId = this.guild!!.id
+ val link = Bot.lava.getLink(guildId)
+ val player = link.player
+ if (link.state == Link.State.NOT_CONNECTED) {
+ MessageUtil.sendEmbedForPublicSlashCommand(
+ this,
+ Color(0xE0A81A),
+ "Not connected",
+ "I'm not in a VC and therefore, I am not playing anything."
+ )
+ return@action
+ }
+ val track = player.playingTrack
+ if (track == null) {
+ MessageUtil.sendEmbedForPublicSlashCommand(
+ this,
+ Color(0xE0A81A),
+ "Not Playing",
+ "I'm not playing anything currently"
+ )
+ return@action
+ }
+ val gts = MusicManager.getGuildTrackScheduler(this.guild!!.asGuild(), player)
+
+ this.respond {
+ this.embeds.add(
+ MessageUtil.getEmbedWithImage(
+ Color(0x52E01A),
+ "Currently playing",
+ "**${track.title}**\n*Now Playing*\nby ${track.author} ; ${
+ TimeUtil.getTimeFormatedRaw(
+ player.position
+ )
+ }: ${
+ TimeUtil.getTimeFormatedRaw(
+ track.length.inWholeMilliseconds
+ )
+ }\n" +
+ ">>>${track.uri}",
+ user.asUser().username + "#" + user.asUser().discriminator,
+ "https://img.youtube.com/vi/" + UrlUtil.getYtThumbnailUrl(track.uri.toString()) + "/maxresdefault.jpg"
+ )
+ )
+
+ this.actionRow {
+ this.components.addAll(
+ ButtonUtil.getMusicControllerButtons(
+ player.paused,
+ gts.repeating
+ ).components
+ )
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/kotlin/net/moonleay/botendo/extensions/music/PlayExtension.kt b/src/main/kotlin/de/limited_dev/botendo/extensions/music/PlayExtension.kt
similarity index 55%
rename from src/main/kotlin/net/moonleay/botendo/extensions/music/PlayExtension.kt
rename to src/main/kotlin/de/limited_dev/botendo/extensions/music/PlayExtension.kt
index 7342c14..301c2c4 100644
--- a/src/main/kotlin/net/moonleay/botendo/extensions/music/PlayExtension.kt
+++ b/src/main/kotlin/de/limited_dev/botendo/extensions/music/PlayExtension.kt
@@ -14,21 +14,22 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
+ *
*/
-package net.moonleay.botendo.extensions.music
+package de.limited_dev.botendo.extensions.music
+import com.kotlindiscord.kord.extensions.commands.Arguments
+import com.kotlindiscord.kord.extensions.commands.converters.impl.string
import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
+import com.kotlindiscord.kord.extensions.types.respond
+import de.limited_dev.botendo.Bot
+import de.limited_dev.botendo.extensions.music.components.MusicManager
+import de.limited_dev.botendo.util.MessageUtil
import dev.kord.common.Color
-import dev.kord.rest.builder.message.embed
import dev.schlaubi.lavakord.audio.Link
import dev.schlaubi.lavakord.kord.getLink
-import net.moonleay.botendo.Bot
-import net.moonleay.botendo.extensions.music.components.LinkArguments
-import net.moonleay.botendo.extensions.music.components.MusicManager
-import net.moonleay.botendo.util.MessageUtil
-import net.moonleay.botendo.util.UserUtil
class PlayExtension : Extension() {
@@ -36,7 +37,7 @@ class PlayExtension : Extension() {
override val name = "play"
override suspend fun setup() {
- publicSlashCommand(::LinkArguments) {
+ publicSlashCommand(::PlayArgs) {
name = "play"
description = "Play music"
this.action {
@@ -46,14 +47,14 @@ class PlayExtension : Extension() {
val vcsUser = u.asMember(guildId).getVoiceStateOrNull()
if (vcsUser == null) {
this.respond {
- this.embed {
- this.color = Color(0xE0311A)
- this.title = "You are not connected to a VC"
- this.description = "Please connect to a VC"
- this.footer {
- this.text = MessageUtil.getFooter(u)
- }
- }
+ embeds.add(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "You are not connected to a VC",
+ "Please connect to a VC",
+ u.asUser().username + "#" + u.asUser().discriminator
+ )
+ )
}
return@action
}
@@ -64,14 +65,14 @@ class PlayExtension : Extension() {
link.connectAudio(channelId!!.value)
} else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) {
this.respond {
- this.embed {
- this.color = Color(0xE0311A)
- this.title = "You are not in my VC"
- this.description = "We are not in the same VC and therefore, you cannot play any music"
- this.author {
- this.name = UserUtil.getCommandSrc(u)
- }
- }
+ embeds.add(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "You are not in my VC",
+ "We are not in the same VC and therefore, you cannot play any music",
+ u.asUser().username + "#" + u.asUser().discriminator
+ )
+ )
}
return@action
}
@@ -83,18 +84,25 @@ class PlayExtension : Extension() {
"ytsearch:$query"
}
this.respond {
- this.embed {
- this.color = Color(0xE0A81A)
- this.title = "Searching..."
- this.description = "We are looking for $query"
- this.footer {
- this.text = MessageUtil.getFooter(u)
- }
- }
+ embeds.add(
+ MessageUtil.getEmbed(
+ Color(0xE0A81A),
+ "Searching...",
+ "We are looking for $query",
+ u.asUser().username + "#" + u.asUser().discriminator
+ )
+ )
}
MusicManager.addToQueue(this, link, search)
}
}
}
+
+ inner class PlayArgs : Arguments() {
+ val linkquery by string {
+ name = "linkqery"
+ description = "Song link or search query"
+ }
+ }
}
diff --git a/src/main/kotlin/net/moonleay/botendo/extensions/music/QueueExtension.kt b/src/main/kotlin/de/limited_dev/botendo/extensions/music/QueueExtension.kt
similarity index 52%
rename from src/main/kotlin/net/moonleay/botendo/extensions/music/QueueExtension.kt
rename to src/main/kotlin/de/limited_dev/botendo/extensions/music/QueueExtension.kt
index f63078a..c27bde5 100644
--- a/src/main/kotlin/net/moonleay/botendo/extensions/music/QueueExtension.kt
+++ b/src/main/kotlin/de/limited_dev/botendo/extensions/music/QueueExtension.kt
@@ -14,21 +14,22 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
+ *
*/
-package net.moonleay.botendo.extensions.music
+package de.limited_dev.botendo.extensions.music
import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
+import com.kotlindiscord.kord.extensions.types.respond
+import de.limited_dev.botendo.Bot
+import de.limited_dev.botendo.extensions.music.components.MusicManager
+import de.limited_dev.botendo.util.ButtonUtil
+import de.limited_dev.botendo.util.MessageUtil
+import de.limited_dev.botendo.util.TimeUtil
import dev.kord.common.Color
-import dev.kord.rest.builder.component.ActionRowBuilder
-import dev.kord.rest.builder.message.actionRow
-import dev.kord.rest.builder.message.embed
+import dev.kord.rest.builder.message.create.actionRow
import dev.schlaubi.lavakord.audio.Link
-import net.moonleay.botendo.extensions.music.components.MusicManager
-import net.moonleay.botendo.util.ButtonUtil
-import net.moonleay.botendo.util.MessageUtil
-import net.moonleay.botendo.util.TimeUtil
class QueueExtension : Extension() {
override val name = "queue"
@@ -38,63 +39,54 @@ class QueueExtension : Extension() {
description = "Show whats up next"
this.action {
val guildId = this.guild!!.id
- val link = net.moonleay.botendo.Bot.lava.getLink(guildId.toString())
+ val link = Bot.lava.getLink(guildId.toString())
val player = link.player
- val u = this.user
if (link.state == Link.State.NOT_CONNECTED) {
- this.respond {
- this.embed {
- this.color = Color(0xE0311A)
- this.title = "Not connected"
- this.description = "I'm not in a VC and therefore, I am not playing anything."
- this.footer {
- this.text = MessageUtil.getFooter(u)
- }
- }
- }
+ MessageUtil.sendEmbedForPublicSlashCommand(
+ this,
+ Color(0xE0311A),
+ "Not connected",
+ "I'm not in a VC and therefore, I am not playing anything."
+ )
return@action
}
val track = player.playingTrack
if (track == null) {
- this.respond {
- this.embed {
- this.color = Color(0xE0311A)
- this.title = "Queue empty"
- this.description = "I'm not playing anything currently"
- this.footer {
- this.text = MessageUtil.getFooter(u)
- }
- }
- }
+ MessageUtil.sendEmbedForPublicSlashCommand(
+ this,
+ Color(0xE0A81A),
+ "Queue empty",
+ "I'm not playing anything currently"
+ )
return@action
}
val gts = MusicManager.getGuildTrackScheduler(this.guild!!.asGuild(), player)
val q = gts.getQueue()
var desc =
- """${"**" + track.info.title + " - " + TimeUtil.getTimeFormatedShortend(track.info.length)} (${track.info.author})**""" + "\n"
+ """${"**" + track.title + " - " + TimeUtil.getTimeFormatedShortend(track.length.inWholeMilliseconds)} (${track.author})**""" + "\n"
for ((i, tr) in q.withIndex()) {
if (i >= 14)
continue
desc += tr.info.title + " - " + TimeUtil.getTimeFormatedShortend(tr.info.length) + " (" + tr.info.author + ")\n"
}
this.respond {
- this.embed {
- this.color = Color(0x52E01A)
- this.title = "Queue"
- this.description = desc
- this.footer {
- this.text = MessageUtil.getFooter(u)
- }
- }
+ this.embeds.add(
+ MessageUtil.getEmbed(
+ Color(0x52E01A),
+ "Queue",
+ desc,
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
- this.actionRow(fun ActionRowBuilder.() {
- components.addAll(
+ this.actionRow {
+ this.components.addAll(
ButtonUtil.getMusicControllerButtons(
player.paused,
gts.repeating
).components
)
- })
+ }
}
}
}
diff --git a/src/main/kotlin/de/limited_dev/botendo/extensions/music/SkipExtension.kt b/src/main/kotlin/de/limited_dev/botendo/extensions/music/SkipExtension.kt
new file mode 100644
index 0000000..8ceb23b
--- /dev/null
+++ b/src/main/kotlin/de/limited_dev/botendo/extensions/music/SkipExtension.kt
@@ -0,0 +1,122 @@
+/*
+ * Botendo
+ * Copyright (C) 2023 moonleay
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package de.limited_dev.botendo.extensions.music
+
+import com.kotlindiscord.kord.extensions.extensions.Extension
+import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
+import com.kotlindiscord.kord.extensions.types.respond
+import de.limited_dev.botendo.Bot
+import de.limited_dev.botendo.extensions.music.components.MusicManager
+import de.limited_dev.botendo.util.ButtonUtil
+import de.limited_dev.botendo.util.MessageUtil
+import de.limited_dev.botendo.util.TimeUtil
+import de.limited_dev.botendo.util.UrlUtil
+import dev.kord.common.Color
+import dev.kord.rest.builder.message.create.actionRow
+import dev.schlaubi.lavakord.audio.Link
+
+class SkipExtension : Extension() {
+ override val name = "skip"
+ override suspend fun setup() {
+ publicSlashCommand {
+ name = "skip"
+ description = "Skip to the next song in queue"
+ this.action {
+ val guildId = this.guild!!.id
+ val link = Bot.lava.getLink(guildId.toString())
+ val player = link.player
+ val u = this.user
+ val voiceState = u.asMember(guildId).getVoiceStateOrNull()
+ if (voiceState == null) {
+ MessageUtil.sendEmbedForPublicSlashCommand(
+ this,
+ Color(0xE0311A),
+ "You are not connected to a VC",
+ "Please connect to a VC"
+ )
+ return@action
+ }
+
+ val channelId = voiceState.channelId
+ if (link.state == Link.State.NOT_CONNECTED) {
+ MessageUtil.sendEmbedForPublicSlashCommand(
+ this,
+ Color(0xE0311A),
+ "Not connected",
+ "I'm not in a VC and therefore, I am not playing anything."
+ )
+ return@action
+ } else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) {
+ MessageUtil.sendEmbedForPublicSlashCommand(
+ this,
+ Color(0xE0311A),
+ "You are not in my VC",
+ "We are not in the same VC and therefore, you cannot control the music"
+ )
+ return@action
+ }
+ var track = player.playingTrack
+ if (track == null) {
+ MessageUtil.sendEmbedForPublicSlashCommand(
+ this,
+ Color(0xE0311A),
+ "Not playing",
+ "I'm not playing anything currently"
+ )
+ return@action
+ }
+ val gts = MusicManager.getGuildTrackScheduler(this.guild!!.asGuild(), player)
+ if (!gts.isEmpty()) {
+ track = gts.getHead().toTrack()
+ gts.playNext(link)
+ } else {
+ player.stopTrack()
+ }
+
+
+ this.respond {
+ this.embeds.add(
+ MessageUtil.getEmbedWithImage(
+ Color(0x52E01A),
+ "Skipped song; now playing",
+ "**${track.title}**\n*Now Playing*\nby ${track.author} :: ${
+ TimeUtil.getTimeFormatedRaw(
+ track.length.inWholeMilliseconds
+ )
+ }\n" +
+ ">>>${track.uri}",
+ "https://img.youtube.com/vi/" + UrlUtil.getYtThumbnailUrl(track.uri!!) + "/maxresdefault.jpg",
+ user.asUser().username + "#" + user.asUser().discriminator
+ )
+ )
+
+ this.actionRow {
+ this.components.addAll(
+ ButtonUtil.getMusicControllerButtons(
+ player.paused,
+ gts.repeating
+ ).components
+ )
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/kotlin/net/moonleay/botendo/extensions/music/StopExtension.kt b/src/main/kotlin/de/limited_dev/botendo/extensions/music/StopExtension.kt
similarity index 53%
rename from src/main/kotlin/net/moonleay/botendo/extensions/music/StopExtension.kt
rename to src/main/kotlin/de/limited_dev/botendo/extensions/music/StopExtension.kt
index 5c0722a..b52330b 100644
--- a/src/main/kotlin/net/moonleay/botendo/extensions/music/StopExtension.kt
+++ b/src/main/kotlin/de/limited_dev/botendo/extensions/music/StopExtension.kt
@@ -14,18 +14,20 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
+ *
*/
-package net.moonleay.botendo.extensions.music
+package de.limited_dev.botendo.extensions.music
import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
+import com.kotlindiscord.kord.extensions.types.respond
+import de.limited_dev.botendo.Bot
+import de.limited_dev.botendo.extensions.music.components.MusicManager
+import de.limited_dev.botendo.util.MessageUtil
import dev.kord.common.Color
-import dev.kord.rest.builder.message.embed
import dev.schlaubi.lavakord.audio.Link
import dev.schlaubi.lavakord.kord.getLink
-import net.moonleay.botendo.extensions.music.components.MusicManager
-import net.moonleay.botendo.util.MessageUtil
class StopExtension : Extension() {
override val name = "stop"
@@ -35,46 +37,44 @@ class StopExtension : Extension() {
description = "Stop playing and start leavin'"
this.action {
val guildId = this.guild!!.id
- val link = net.moonleay.botendo.Bot.lava.getLink(guildId)
+ val link = Bot.lava.getLink(guildId)
val player = link.player
val u = this.user
val vcsUser = u.asMember(guildId).getVoiceStateOrNull()
if (vcsUser == null) {
this.respond {
- this.embed {
- this.color = Color(0xE0311A)
- this.title = "You are not connected to a VC"
- this.description = "Please connect to a VC"
- this.footer {
- this.text = MessageUtil.getFooter(u)
- }
- }
+ this.embeds.add(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "You are not connected to a VC",
+ "Please connect to my VC", u.asUser().username + "#" + u.asUser().discriminator
+ )
+ )
}
return@action
}
val channelId = vcsUser.channelId
if (link.state == Link.State.NOT_CONNECTED) {
this.respond {
- this.embed {
- this.color = Color(0xE0311A)
- this.title = "Not connected"
- this.description = "I'm not in a VC and therefore, I am not playing anything."
- this.footer {
- this.text = MessageUtil.getFooter(u)
- }
- }
+ this.embeds.add(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "Not connected",
+ "I'm not in a VC and therefore, I am not playing anything.",
+ u.asUser().username + "#" + u.asUser().discriminator
+ )
+ )
}
return@action
} else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) {
this.respond {
- this.embed {
- this.color = Color(0xE0311A)
- this.title = "You are not in my VC"
- this.description = "We are not in the same VC"
- this.footer {
- this.text = MessageUtil.getFooter(u)
- }
- }
+ this.embeds.add(
+ MessageUtil.getEmbed(
+ Color(0xE0311A),
+ "You are not in my VC",
+ "We are not in the same VC", u.asUser().username + "#" + u.asUser().discriminator
+ )
+ )
}
return@action
}
@@ -82,14 +82,14 @@ class StopExtension : Extension() {
link.destroy()
MusicManager.getGuildTrackScheduler(this.getGuild()!!.asGuild(), player).clear()
this.respond {
- this.embed {
- this.color = Color(0x52E01A)
- this.title = "I stopped and left"
- this.description = "just like your girlfriend"
- this.footer {
- this.text = MessageUtil.getFooter(u)
- }
- }
+ this.embeds.add(
+ MessageUtil.getEmbed(
+ Color(0x52E01A),
+ "I stopped and left",
+ "just like your girlfriend",
+ u.asUser().username + "#" + u.asUser().discriminator
+ )
+ )
}
}
}
diff --git a/src/main/kotlin/net/moonleay/botendo/extensions/music/components/GuildTrackScheduler.kt b/src/main/kotlin/de/limited_dev/botendo/extensions/music/components/GuildTrackScheduler.kt
similarity index 71%
rename from src/main/kotlin/net/moonleay/botendo/extensions/music/components/GuildTrackScheduler.kt
rename to src/main/kotlin/de/limited_dev/botendo/extensions/music/components/GuildTrackScheduler.kt
index ed90f17..992fee8 100644
--- a/src/main/kotlin/net/moonleay/botendo/extensions/music/components/GuildTrackScheduler.kt
+++ b/src/main/kotlin/de/limited_dev/botendo/extensions/music/components/GuildTrackScheduler.kt
@@ -14,49 +14,37 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
+ *
*/
-package net.moonleay.botendo.extensions.music.components
+package de.limited_dev.botendo.extensions.music.components
-import dev.arbjerg.lavalink.protocol.v4.Track
+import de.limited_dev.botendo.Bot
+import de.limited_dev.botendo.util.Logger
import dev.schlaubi.lavakord.audio.*
import dev.schlaubi.lavakord.audio.player.Player
-import net.moonleay.botendo.Bot
-import net.moonleay.botendo.util.Logger
+import dev.schlaubi.lavakord.rest.models.PartialTrack
import java.util.concurrent.BlockingQueue
import java.util.concurrent.LinkedBlockingQueue
class GuildTrackScheduler(val pl: Player) {
- private var queue: BlockingQueue