From 659fc6a6b6b35d0c0ad7960697c1486ce1ea22bb Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Wed, 24 Apr 2024 20:19:36 +0100 Subject: [PATCH] Add admonition documenting lack of DM channel caching (#561) * Add admonition documenting lack of DM channel caching * Fix typo Co-authored-by: jchristgit --------- Co-authored-by: jchristgit --- 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..79858d80d 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 (ETS, Mnesia, etc.). + ### Example ```elixir