Skip to content

Commit

Permalink
Cache presences on guild member chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
BartArys committed Jul 24, 2020
1 parent 8158d60 commit 914867c
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.gitlab.kordlib.core.gateway.handler

import com.gitlab.kordlib.cache.api.DataCache
import com.gitlab.kordlib.cache.api.put
import com.gitlab.kordlib.cache.api.putAll
import com.gitlab.kordlib.cache.api.query
import com.gitlab.kordlib.common.entity.Snowflake
import com.gitlab.kordlib.core.Kord
Expand Down Expand Up @@ -213,6 +214,9 @@ internal class GuildEventHandler(
}

private suspend fun handle(event: GuildMembersChunk, shard: Int) = with(event.data) {
val presences = presences.orEmpty().map { PresenceData.from(guildId, it) }
cache.putAll(presences)

val members = members.asFlow().map { member ->
val memberData = MemberData.from(member.user!!.id, guildId, member)
cache.put(memberData)
Expand Down

0 comments on commit 914867c

Please sign in to comment.