🧩 KPresence
📦 A lightweight, cross-platform Kotlin Multiplatform library for interacting with Discord Rich Presence.
💎 Features
- Cross-platform compatibility (Windows, Linux, macOS)
- Fast and user-friendly
- Offers DSL support
- Provides both JVM and Native implementations
- Validates the activity fields before sending them
- Supports Flatpak and Snap installations on Linux
- Ability to extend and override the default search paths
🔌 Requirements
- Java:
16 or later (only for use within the JVM environment)
⚙️ Installation
dependencies {
implementation("io.github.vyfor:kpresence:0.6.6")
}
✨ Examples
Initial connection and presence updates
val client = RichClient(CLIENT_ID)
client.connect()
client.update {
type = ActivityType.GAME
details = "Exploring Kotlin Native"
state = "Writing code"
timestamps {
start = now() -
end = now() +
}
party {
id =
size(current = , max = )
}
assets {
largeImage =
largeText =
smallImage =
smallText =
}
secrets {
join =
spectate =
match =
}
button(, )
button(, )
}
Event handling
val client = RichClient(CLIENT_ID)
client.on<ReadyEvent> {
update(activity)
}
client.on<ActivityUpdateEvent> {
logger?.info("Updated rich presence")
}
client.on<DisconnectEvent> {
connect(shouldBlock = true)
}
client.connect(shouldBlock = false)
Logging
val client = RichClient(CLIENT_ID)
client.logger = ILogger.default()