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

Store all channels in channel cache #556

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions lib/nostrum/shard/dispatch.ex
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,12 @@ defmodule Nostrum.Shard.Dispatch do
def handle_event(:AUTO_MODERATION_RULE_EXECUTION = event, p, state),
do: {event, AutoModerationRuleExecute.to_struct(p), state}

def handle_event(:CHANNEL_CREATE = event, %{type: t} = p, state) when t in [0, 2] do
def handle_event(:CHANNEL_CREATE = event, p, state) do
ChannelGuildMapping.create(p.id, p.guild_id)
{event, GuildCache.channel_create(p.guild_id, p), state}
end

# Ignore group channels
def handle_event(:CHANNEL_CREATE, _p, _state) do
:noop
end

def handle_event(:CHANNEL_DELETE = event, %{type: t} = p, state) when t in [0, 2] do
def handle_event(:CHANNEL_DELETE = event, p, state) do
ChannelGuildMapping.delete(p.id)
{event, GuildCache.channel_delete(p.guild_id, p.id), state}
end
Expand All @@ -108,11 +103,6 @@ defmodule Nostrum.Shard.Dispatch do
{event, GuildCache.channel_update(p.guild_id, p), state}
end

def handle_event(:CHANNEL_DELETE, _p, _state) do
# Ignore group channels
:noop
end

def handle_event(:CHANNEL_PINS_ACK = event, p, state), do: {event, p, state}

def handle_event(:CHANNEL_PINS_UPDATE = event, p, state) do
Expand Down
Loading