vyfor / KPresence

πŸ“¦ A lightweight, cross-platform Kotlin library for Discord Rich Presence interaction.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🧩 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

πŸ”Œ Requirements

  • Java: 16 or later (only for use within the JVM environment)

βš™οΈ Installation

dependencies {
    implementation("io.github.vyfor:kpresence:0.5.2")
}

✨ Examples

Initial connection and presence updates

val client = RichClient(CLIENT_ID)
  
client.connect()

val activity = activity {
    type = ActivityType.GAME
    details = "Exploring Kotlin Native"
    state = "Writing code"
    
    timestamps {
        start = epochMillis() - 3600_000
        end = epochMillis() + 3600_000
    }
    
    party {
      id = "myParty"
      size(current = 1, max = 5)
    }
    
    assets {
        largeImage = "kotlin_logo"
        largeText = "Kotlin"
        smallImage = "jetbrains_logo"
        smallText = "JetBrains"
    }
    
    secrets {
        join = "joinSecret"
        spectate = "spectateSecret"
        match = "matchSecret"
    }
    
    button("Learn more", "https://kotlinlang.org/")
    button("Try it yourself", "https://play.kotlinlang.org/")
}

client.update(activity)

Enable logging

val client = RichClient(CLIENT_ID)
client.logger = ILogger.default()

About

πŸ“¦ A lightweight, cross-platform Kotlin library for Discord Rich Presence interaction.

License:MIT License


Languages

Language:Kotlin 100.0%