Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Fixed an issue with channel and user in voice state (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
RealYusufIsmail authored Sep 9, 2023
1 parent fe01a03 commit 479a46a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Kotlin](https://img.shields.io/badge/kotlin-1.9.0-blue.svg?logo=kotlin)](http://kotlinlang.org)
[![codecov](https://codecov.io/gh/YDWK/YDWK/branch/master/graph/badge.svg?token=LKIA8T6N6J)](https://codecov.io/gh/YDWK/YDWK)
[![yde](https://img.shields.io/badge/YDE--Version-v1.2.0-blue)](https://github.com/YDWK/YDE/releases/tag/v1.2.0)
[![yde](https://img.shields.io/badge/YDE--Version-v1.3.0-blue)](https://github.com/YDWK/YDE/releases/tag/v1.3.0)

# YDE

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
kotlin.code.style=official
version= 1.2.0
version= 1.3.0

jvmVersion = 1.9.0
pluginAllOpenVersion = 1.9.0
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/github/ydwk/yde/entities/VoiceState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ interface VoiceState : GenericEntity {
*
* @return The user this voice state is for.
*/
val user: User
val user: User?

/**
* The guild member this voice state is for.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,15 @@ class VoiceStateImpl(

override val channel: GuildVoiceChannel?
get() =
if (json.has("channel_id")) {
if (json.hasNonNull("channel_id") || json.get("channel_id").asText() != "null") {
if (yde.getGuildChannelGetterById(json["channel_id"].asText()) != null)
yde.getGuildChannelGetterById(json["channel_id"].asText())!!
.asGuildVoiceChannel()
else null
} else null

override val user: User
get() =
yde.getUserById(json["user_id"].asLong())
?: throw NullPointerException("User not found")
override val user: User?
get() = yde.getUserById(json["user_id"].asLong())

override val member: Member?
get() =
Expand Down

0 comments on commit 479a46a

Please sign in to comment.