Skip to content

Commit

Permalink
Add admonition documenting lack of DM channel caching
Browse files Browse the repository at this point in the history
  • Loading branch information
jb3 authored Apr 24, 2024
1 parent 5107db0 commit 416b91c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/nostrum/struct/channel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 416b91c

Please sign in to comment.