8000 GitHub - kordlib/Lavalink.kt at 0.3
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

kordlib/Lavalink.kt

Repository files navigation

Lavakord

Extension of the official LavaLink-Client to work with Kord

Both Kord and Lavakord is still in an experimental stage, as such we can't guarantee API stability between releases. While we'd love for you to try out our library, we don't recommend you use this in production just yet.

Lavalink download: https://github.com/Frederikam/Lavalink

Download

You can get Lavakord from here: https://package-search.jetbrains.com/package?id=me.schlaubi%3Alavakord (You need jcenter() and jitpack though)

Usage

You can create a Lavalink object like this

    val lavalink = kord.lavalink()

    // or    

    val lavalink = kord.lavalink {
            autoReconnect = false
    }

You can obtain and use a Link like this

    val link = guild.getLink(lavalink)

    link.connect(channel)

    // use lavalink stuff like player

    link.disconnect()

Playing: https://github.com/DRSchlaubi/Lavakord/blob/master/example/src/main/kotlin/me/schlaubi/lavakord/example/Lavakord.kt#L101-L122

Track loading

Lavakord provides a wrapper for the Lavalink Track loading API

You can load a Track by using Link.loadItem(query: String) for a couroutine based aproach or Link.loadItem(query: String, callback: AudioLoadResultHandler) for a callback based approach like Lavaplayer

Events

Since 0.3 Lavakord provides a Flow based way to listen for events.

val link: KordLink // = .../

val player = link.player

player.on<TrackStartEvent> {
    channel.createMessage(track.info.asString())
}

Documentation

For more info please use the example or Dokka docs

0