diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eab6e3dcd4..51a140cbbd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 0.5.8 + +## Fixes + +* Fixed an issue where getting a channel from a guild would incorrectly throw an exception during the guild id check. + # 0.5.7 ## Additions 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 8cb947eaef7..a774bcb7231 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 @@ -18,7 +18,6 @@ import com.gitlab.kordlib.core.supplier.getChannelOfOrNull import com.gitlab.kordlib.rest.builder.ban.BanCreateBuilder import com.gitlab.kordlib.rest.builder.channel.* import com.gitlab.kordlib.rest.builder.guild.EmojiCreateBuilder -import com.gitlab.kordlib.rest.builder.guild.EmojiModifyBuilder import com.gitlab.kordlib.rest.builder.guild.GuildModifyBuilder import com.gitlab.kordlib.rest.builder.role.RoleCreateBuilder import com.gitlab.kordlib.rest.builder.role.RolePositionsModifyBuilder @@ -509,29 +508,29 @@ suspend inline fun GuildBehavior.ban(userId: Snowflake, builder: BanCreateBuilde } /** - * Requests to get the [GuildChannel] represented by the [id] as type [T]. + * Requests to get the [GuildChannel] represented by the [channelId] as type [T]. * * @throws [RequestException] if anything went wrong during the request. * @throws [EntityNotFoundException] if the [T] wasn't present. * @throws [ClassCastException] if the channel is not of type [T]. * @throws [IllegalArgumentException] if the channel is not part of this guild. */ -suspend inline fun GuildBehavior.getChannelOf(id: Snowflake) : T { - val channel = supplier.getChannelOf(id) - require(channel.guildId == id) { "channel ${id.value} is not in guild ${id.value}" } +suspend inline fun GuildBehavior.getChannelOf(channelId: Snowflake) : T { + 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] as type [T], + * Requests to get the [GuildChannel] represented by the [channelId] as type [T], * returns null if the [GuildChannel] isn't present. * * @throws [RequestException] if anything went wrong during the request. * @throws [ClassCastException] if the channel is not of type [T]. * @throws [IllegalArgumentException] if the channel is not part of this guild. */ -suspend inline fun GuildBehavior.getChannelOfOrNull(id: Snowflake) : T? { - val channel = supplier.getChannelOfOrNull(id) ?: return null - require(channel.guildId == id) { "channel ${id.value} is not in guild ${id.value}" } +suspend inline fun GuildBehavior.getChannelOfOrNull(channelId: Snowflake) : T? { + val channel = supplier.getChannelOfOrNull(channelId) ?: return null + require(channel.guildId == this.id) { "channel ${channelId.value} is not in guild ${this.id.value}" } return channel }