diff --git a/core/src/commonMain/kotlin/supplier/StoreEntitySupplier.kt b/core/src/commonMain/kotlin/supplier/StoreEntitySupplier.kt index d54703aa4de..3404a634c86 100644 --- a/core/src/commonMain/kotlin/supplier/StoreEntitySupplier.kt +++ b/core/src/commonMain/kotlin/supplier/StoreEntitySupplier.kt @@ -60,9 +60,11 @@ public class StoreEntitySupplier( } - override suspend fun getMemberOrNull(guildId: Snowflake, userId: Snowflake): Member? { - return storeAndReturn(supplier.getMemberOrNull(guildId, userId)) { it.memberData } - } + override suspend fun getMemberOrNull(guildId: Snowflake, userId: Snowflake): Member? = + supplier.getMemberOrNull(guildId, userId)?.also { member -> + cache.put(member.data) + cache.put(member.memberData) + } override suspend fun getMessageOrNull(channelId: Snowflake, messageId: Snowflake): Message? { return storeAndReturn(supplier.getMessageOrNull(channelId, messageId)) { it.data } @@ -104,9 +106,11 @@ public class StoreEntitySupplier( return storeOnEach(supplier.getGuildBans(guildId, limit)) { it.data } } - override fun getGuildMembers(guildId: Snowflake, limit: Int?): Flow { - return storeOnEach(supplier.getGuildMembers(guildId, limit)) { it.memberData } - } + override fun getGuildMembers(guildId: Snowflake, limit: Int?): Flow = + supplier.getGuildMembers(guildId, limit).onEach { member -> + cache.put(member.data) + cache.put(member.memberData) + } override fun getGuildVoiceRegions(guildId: Snowflake): Flow { return storeOnEach(supplier.getGuildVoiceRegions(guildId)) { it.data }