From 359fc1a319c6ac11aca029c205005e5cbec96164 Mon Sep 17 00:00:00 2001 From: BartArys Date: Sun, 19 Jul 2020 20:43:57 +0200 Subject: [PATCH] Fix receiver issue when getting channel from guild (again) --- CHANGELOG.md | 8 ++++++++ .../kordlib/core/behavior/GuildBehavior.kt | 16 ++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51a140cbbd1..e3a9293f82d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# 0.5.9 + +## Fixes + +* Fixed an issue where getting a channel from a guild would incorrectly throw an exception during the guild id check. +(again) + + # 0.5.8 ## Fixes diff --git a/core/src/main/kotlin/com/gitlab/kordlib/core/behavior/GuildBehavior.kt b/core/src/main/kotlin/com/gitlab/kordlib/core/behavior/GuildBehavior.kt index a774bcb7231..4e09b7295f4 100644 --- a/core/src/main/kotlin/com/gitlab/kordlib/core/behavior/GuildBehavior.kt +++ b/core/src/main/kotlin/com/gitlab/kordlib/core/behavior/GuildBehavior.kt @@ -259,30 +259,30 @@ interface GuildBehavior : Entity, Strategizable { suspend fun getBanOrNull(userId: Snowflake): Ban? = supplier.getGuildBanOrNull(id, userId) /** - * Requests to get the [GuildChannel] represented by the [id]. + * Requests to get the [GuildChannel] represented by the [channelId]. * * @throws [RequestException] if anything went wrong during the request. * @throws [EntityNotFoundException] if the [GuildChannel] wasn't present. * @throws [ClassCastException] if the channel is not a [GuildChannel]. * @throws [IllegalArgumentException] if the channel is not part of this guild. */ - suspend fun getChannel(id: Snowflake) : GuildChannel { - val channel = supplier.getChannelOf(id) - require(channel.guildId == id) { "channel ${id.value} is not in guild ${id.value}" } + suspend fun getChannel(channelId: Snowflake) : GuildChannel { + val channel = supplier.getChannelOf(channelId) + require(channel.guildId == this.id) { "channel ${channelId.value} is not in guild ${this.id.value}" } return channel } /** - * Requests to get the [GuildChannel] represented by the [id], + * Requests to get the [GuildChannel] represented by the [channelId], * returns null if the [GuildChannel] isn't present. * * @throws [RequestException] if anything went wrong during the request. * @throws [ClassCastException] if the channel is not a [GuildChannel]. * @throws [IllegalArgumentException] if the channel is not part of this guild. */ - suspend fun getChannelOrNull(id: Snowflake) : GuildChannel? { - val channel = supplier.getChannelOfOrNull(id) ?: return null - require(channel.guildId == id) { "channel ${id.value} is not in guild ${id.value}" } + suspend fun getChannelOrNull(channelId: Snowflake) : GuildChannel? { + val channel = supplier.getChannelOfOrNull(channelId) ?: return null + require(channel.guildId == this.id) { "channel ${channelId.value} is not in guild ${this.id.value}" } return channel }