Skip to content

Commit

Permalink
only cache messages sent in guild channels
Browse files Browse the repository at this point in the history
  • Loading branch information
FloatingMilkshake committed Mar 17, 2024
1 parent ddbff93 commit bd042e3
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions Events/MessageEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ public static Task MessageUpdated(DiscordClient _, MessageUpdateEventArgs e)
{
await ThrowMessageException(ex, e.Message, true);
}

// Add message to cache
Program.LastMessageCache[e.Channel.Id] = e.Message;

if (!e.Channel.IsPrivate)
{
// Add message to cache
Program.LastMessageCache[e.Channel.Id] = e.Message;
}
});
return Task.CompletedTask;
}
Expand All @@ -31,12 +34,13 @@ public static Task MessageCreated(DiscordClient client, MessageCreateEventArgs e
try
{
await KeywordTrackingHelpers.KeywordCheck(e.Message);

// Add message to cache
Program.LastMessageCache[e.Channel.Id] = e.Message;

if (!e.Channel.IsPrivate)
return;
{
// Add message to cache
Program.LastMessageCache[e.Channel.Id] = e.Message;
return;
}

if (e.Author.IsCurrent)
return;
Expand Down

0 comments on commit bd042e3

Please sign in to comment.