Skip to content

Commit

Permalink
Improvments
Browse files Browse the repository at this point in the history
- Fix formatting
- Add destructuring functions to JDA
- Make connect no longer an extension
 - Fix track decoding
 - Add support for custom track fields
  • Loading branch information
DRSchlaubi committed Aug 1, 2023
1 parent d88b7c9 commit 96381a9
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "dev.schlaubi.lavakord"
version = "5.1.2"
version = "5.1.3"

allprojects {
repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ import kotlinx.coroutines.launch
* @see EventSource.on
*/
public interface EventSource<T> {

public val events: Flow<T>
public val coroutineScope: CoroutineScope

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public interface Link {
/**
* Connects this link to the voice channel with the specified [voiceChannelId].
*/
public suspend fun Link.connect(voiceChannelId: String): Unit = connectAudio(voiceChannelId.toULong())
public suspend fun connect(voiceChannelId: String): Unit = connectAudio(voiceChannelId.toULong())

/**
* Disconnects from the currently connected voice channel.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public data class LavaplayerTrack(
val isSeekable = !isStream
val uri = if (reader.readBoolean()) reader.readUTF() else null
val source = reader.readUTF()
reader.discard((reader.availableForRead - Long.SIZE_BYTES).toLong())
val position = reader.readLong()

return LavaplayerTrack(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public suspend inline fun <reified T, reified Resource : Any> RestNode.request(
@PublishedApi
internal val RestNode.restClient: HttpClient
get() {
val lavakord = this.lavakord as? AbstractLavakord ?: error("Only supported on default implementation")
val lavakord = this.lavakord as? AbstractLavakord
?: error("Only supported on default implementation")
return lavakord.restClient
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ public suspend fun RestNode.decodeTrack(base64: String): Track = get(V4Api.Decod
* **Note:** This makes an API call, if you want to do this locally use [LavaplayerTrack.fromLavalink]
*/
public suspend fun RestNode.decodeTracks(tracks: Iterable<String>): List<Track> = post(V4Api.DecodeTrack()) {
setBody(tracks)
setBody(tracks.toList())
}
15 changes: 15 additions & 0 deletions jda/src/jvmMain/kotlin/dev/schlaubi/lavakord/jda/JDA.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import net.dv8tion.jda.api.sharding.ShardManager
*/
public interface LavakordJdaBase {
public val lavakord: LavaKord

/**
* Destructuring accessor for [lavakord].
*/
public operator fun component1(): LavaKord = lavakord
}

/**
Expand All @@ -23,6 +28,11 @@ public interface LavakordJdaBase {
*/
public interface LJDA : LavakordJdaBase {
public val jda: JDA

/**
* Destructuring accessor for [jda].
*/
public operator fun component2(): JDA = jda
}

/**
Expand All @@ -32,6 +42,11 @@ public interface LJDA : LavakordJdaBase {
*/
public interface LShardManager : LavakordJdaBase {
public val shardManager: ShardManager

/**
* Destructuring accessor for [shardManager].
*/
public operator fun component2(): ShardManager = shardManager
}

/**
Expand Down

0 comments on commit 96381a9

Please sign in to comment.