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

Filter out non-guilds when fetching rest guilds #301

Merged
merged 1 commit into from
Jun 4, 2021
Merged
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
9 changes: 3 additions & 6 deletions core/src/main/kotlin/supplier/RestEntitySupplier.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ import dev.kord.rest.json.request.AuditLogGetRequest
import dev.kord.rest.request.RestRequestException
import dev.kord.rest.route.Position
import dev.kord.rest.service.*
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.take
import kotlinx.coroutines.flow.*
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.InvocationKind
import kotlin.contracts.contract
Expand Down Expand Up @@ -74,8 +71,8 @@ class RestEntitySupplier(val kord: Kord) : EntitySupplier {

override fun getGuildChannels(guildId: Snowflake): Flow<GuildChannel> = flow {
for (channelData in guild.getGuildChannels(guildId))
emit(Channel.from(ChannelData.from(channelData), kord) as GuildChannel)
}
emit(Channel.from(ChannelData.from(channelData), kord))
}.filterIsInstance()

override fun getChannelPins(channelId: Snowflake): Flow<Message> = flow {
for (messageData in channel.getChannelPins(channelId))
Expand Down