Skip to content

Commit

Permalink
Fix return type of channel in VoiceState (kordlib#295)
Browse files Browse the repository at this point in the history
* Fix return type of channel in VoiceState

* Fix GuildService#modifyVoiceState endpoint
  • Loading branch information
HopeBaron authored and DRSchlaubi committed Jun 7, 2021
1 parent 4b0d10c commit af3a6de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions core/src/main/kotlin/entity/VoiceState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import dev.kord.common.annotation.DeprecatedSinceKord
import dev.kord.common.entity.Snowflake
import dev.kord.core.Kord
import dev.kord.core.KordObject
import dev.kord.core.behavior.channel.BaseVoiceChannelBehavior
import dev.kord.core.cache.data.VoiceStateData
import dev.kord.core.entity.channel.VoiceChannel
import dev.kord.core.supplier.EntitySupplier
Expand Down Expand Up @@ -51,15 +52,15 @@ class VoiceState(
*/
@DeprecatedSinceKord("0.7.0")
@Deprecated("Use getChannelOrNull instead.", ReplaceWith("getChannelOrNull"), DeprecationLevel.ERROR)
suspend fun getChannel(): VoiceChannel? = channelId?.let { supplier.getChannelOfOrNull(it) }
suspend fun getChannel(): BaseVoiceChannelBehavior? = channelId?.let { supplier.getChannelOfOrNull(it) }

/**
* Requests to get the voice channel through the [strategy],
* returns null if the [VoiceChannel] isn't present.
*
* @throws [RequestException] if anything went wrong during the request.
*/
suspend fun getChannelOrNull(): VoiceChannel? = channelId?.let { supplier.getChannelOfOrNull(it) }
suspend fun getChannelOrNull(): BaseVoiceChannelBehavior? = channelId?.let { supplier.getChannelOfOrNull(it) }


/**
Expand Down
2 changes: 1 addition & 1 deletion rest/src/main/kotlin/service/GuildService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ class GuildService(requestHandler: RequestHandler) : RestService(requestHandler)


suspend fun modifyVoiceState(guildId: Snowflake, userId: Snowflake, request: VoiceStateModifyRequest) =
call(Route.SelfVoiceStatePatch) {
call(Route.OthersVoiceStatePatch) {
keys[Route.GuildId] = guildId
keys[Route.UserId] = userId
body(VoiceStateModifyRequest.serializer(), request)
Expand Down

0 comments on commit af3a6de

Please sign in to comment.