tulpje_cache/models/
integration.rs1use twilight_model::{
2 guild::GuildIntegration,
3 id::{
4 Id,
5 marker::{GuildMarker, IntegrationMarker},
6 },
7};
8
9use crate::{Cache, Error, GuildResource};
10
11pub use twilight_model::guild::GuildIntegration as CachedGuildIntegration;
12
13impl Cache {
14 pub(crate) async fn cache_integration(
15 &self,
16 guild_id: Id<GuildMarker>,
17 integration: &GuildIntegration,
18 ) -> Result<(), Error> {
19 self.guild_integrations
20 .insert(&guild_id, &integration.id)
21 .await?;
22
23 self.integrations
24 .insert(
25 &(guild_id, integration.id),
26 &GuildResource {
27 guild_id,
28 value: integration.clone(),
29 },
30 )
31 .await?;
32
33 Ok(())
34 }
35
36 pub(crate) async fn delete_integration(
37 &self,
38 guild_id: Id<GuildMarker>,
39 integration_id: Id<IntegrationMarker>,
40 ) -> Result<(), Error> {
41 self.integrations
42 .remove(&(guild_id, integration_id))
43 .await?;
44
45 self.guild_integrations
46 .remove(&guild_id, &integration_id)
47 .await?;
48
49 Ok(())
50 }
51}