Skip to content

Commit

Permalink
Merge pull request #556 from Kraigie/jb3/cache-all-channels
Browse files Browse the repository at this point in the history
Store all channels in channel cache
  • Loading branch information
jb3 authored Apr 19, 2024
2 parents 984e052 + 0e35805 commit 5aa66bd
Showing 1 changed file with 2 additions and 12 deletions.
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

0 comments on commit 5aa66bd

Please sign in to comment.