Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ChannelCache documentation enhancements #537

Closed
jb3 opened this issue Apr 17, 2024 · 1 comment · Fixed by #555
Closed

ChannelCache documentation enhancements #537

jb3 opened this issue Apr 17, 2024 · 1 comment · Fixed by #555

Comments

@jb3
Copy link
Collaborator

jb3 commented Apr 17, 2024

Whilst it is mentioned in the documentation that the ChannelCache only stores DMChannels, I think we should make this more clear to the user, my proposals are:

  • We rename this structure to DMChannelCache, as it is not a generic channel cache
  • We add a warning to the docs instead of just having this feature in the blurb

This is based off the fact that several users in the nostrum channel have been confused by this behavior, including myself at first. We did change this behavior and as such I think we should make it as clear as possible that this is how it works. At the very least, if users get errors about the ChannelCache module rename it should prompt them to check they are actually using it as intended.

We could also include a code sample like the following on how to get a GuildChannel:

iex(20)> channel_id = 1229955694258684005
1229955694258684005
iex(21)> guild_id = Nostrum.Cache.ChannelGuildMapping.get(channel_id)
1226944827137069107
iex(22)> {:ok, guild} = Nostrum.Cache.GuildCache.get(guild_id)
{:ok,
 %Nostrum.Struct.Guild{
   id: 1226944827137069107,
   name: "nostrum test",
   ...
 }}
iex(24)> guild.channels[channel_id].name
"test"
@jchristgit
Copy link
Collaborator

This sounds good to me.

One alternative: we split the guild channels out of the guild struct and incorporate them into the channel cache. I don't think this makes much sense though, because to my knowledge guild channels have a lot of attributes that regular channels do not.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
Status: Done
2 participants