From 416b91c590c81a56eac8fdf021584a32ca0105be Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Wed, 24 Apr 2024 19:39:04 +0100 Subject: [PATCH 1/2] Add admonition documenting lack of DM channel caching --- lib/nostrum/struct/channel.ex | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/nostrum/struct/channel.ex b/lib/nostrum/struct/channel.ex index 70adfa323..82472a5bd 100644 --- a/lib/nostrum/struct/channel.ex +++ b/lib/nostrum/struct/channel.ex @@ -35,6 +35,16 @@ defmodule Nostrum.Struct.Channel do Once you have a guild ID, you can use the `Nostrum.Cache.GuildCache` to fetch the guild and all channels, then use the `t:Nostrum.Struct.Guild.channels/0` field to find the channel. + > #### Note on DM Channels {: .tip} + > + > The `Nostrum.Cache.ChannelGuildMapping` by design only caches a mapping of channels to their respective guilds, and the stored channel object sits within the `Nostrum.Cache.GuildCache`. + > + > Due to how Direct Message channels work (no `CHANNEL_CREATE` events, not sent in any gateway events, etc.), we make no attempt to store direct message channels within any of the + > built-in Nostrum caching adapters. + > + > If you wish to implement this functionality yourself, you will have to fetch the channel details from the API by looking at the `channel_id` field of received message objects, + > you can then store these details in your own choice of caching system (ETC, Mnesia, etc.). + ### Example ```elixir From d17ff3d932995626d6bdf3baae386599037cd4a4 Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Wed, 24 Apr 2024 20:18:47 +0100 Subject: [PATCH 2/2] Fix typo Co-authored-by: jchristgit --- lib/nostrum/struct/channel.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nostrum/struct/channel.ex b/lib/nostrum/struct/channel.ex index 82472a5bd..79858d80d 100644 --- a/lib/nostrum/struct/channel.ex +++ b/lib/nostrum/struct/channel.ex @@ -43,7 +43,7 @@ defmodule Nostrum.Struct.Channel do > built-in Nostrum caching adapters. > > If you wish to implement this functionality yourself, you will have to fetch the channel details from the API by looking at the `channel_id` field of received message objects, - > you can then store these details in your own choice of caching system (ETC, Mnesia, etc.). + > you can then store these details in your own choice of caching system (ETS, Mnesia, etc.). ### Example