Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't retrieve unknown channels as guildchannels #251

Merged
merged 1 commit into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/main/kotlin/supplier/CacheEntitySupplier.kt
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class CacheEntitySupplier(private val kord: Kord) : EntitySupplier {

override fun getGuildChannels(guildId: Snowflake): Flow<GuildChannel> = cache.query<ChannelData> {
idEq(ChannelData::guildId, guildId)
}.asFlow().map { Channel.from(it, kord) as GuildChannel }
}.asFlow().map { Channel.from(it, kord) }.filterIsInstance()

override fun getChannelPins(channelId: Snowflake): Flow<Message> = cache.query<MessageData> {
idEq(MessageData::channelId, channelId)
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/kotlin/supplier/EntitySupplier.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import dev.kord.core.entity.channel.GuildChannel
import dev.kord.core.entity.channel.MessageChannel
import dev.kord.core.exception.EntityNotFoundException
import kotlinx.coroutines.flow.Flow
import dev.kord.common.entity.ChannelType.Unknown

/**
* An abstraction that allows for requesting Discord entities.
Expand Down Expand Up @@ -87,7 +88,7 @@ interface EntitySupplier {
suspend fun getChannel(id: Snowflake): Channel = getChannelOrNull(id)!!

/**
* Requests the [channels][GuildChannel] of the [Guild] with the given [guildId].
* Requests the [channels][GuildChannel] of the [Guild] with the given [guildId], channels with an [Unknown] type will be filtered out of the list.
*
* The returned flow is lazily executed, any [RequestException] will be thrown on
* [terminal operators](https://kotlinlang.org/docs/reference/coroutines/flow.html#terminal-flow-operators) instead.
Expand Down