Skip to content

fix(Discord): Unfuck Discord rpc#279

Open
IceTank wants to merge 2 commits intolambda-client:1.21.11from
IceTank:fix/discord-rpc
Open

fix(Discord): Unfuck Discord rpc#279
IceTank wants to merge 2 commits intolambda-client:1.21.11from
IceTank:fix/discord-rpc

Conversation

@IceTank
Copy link
Copy Markdown
Contributor

@IceTank IceTank commented Mar 25, 2026

This change lazy loads the Discord integration dependency, removing around a 10-second unavoidable delay when starting the game.
This also fixes the module starting the Discord RPC integration even if the module is disabled.

@beanbag44 beanbag44 self-requested a review March 25, 2026 19:05
if (rpc == null) {
rpc = KDiscordIPC(Lambda.APP_ID, scope = EventFlow.lambdaScope)
}
if (rpc!!.connected) return true
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we, if not never, almost never use !! as it voids kotlins null safety checks and opens space up for null pointer exceptions


onEnable { runConcurrent { start(); handleLoop() } }
runConcurrent { start() }
onEnable {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the only place start() is called which will not run if the user has the module enabled on client startup as onEnable requires a SafeContext

private val line2Right by setting("Line 2 Right", LineInfo.Fps)

val rpc = KDiscordIPC(Lambda.APP_ID, scope = EventFlow.lambdaScope)
var rpc: KDiscordIPC? = null
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this be replaced with a lazy {}?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants