Skip to content

Commit

Permalink
quick fixes for .recentmessages
Browse files Browse the repository at this point in the history
  • Loading branch information
Ixrec committed Nov 9, 2023
1 parent 7819c12 commit ac70050
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Izzy-Moonbot/Modules/ModMiscModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ public async Task SetBannnerCommandAsync([Remainder] string url = "")

[Command("recentmessages")]
[Summary("Dump all of the recent messages Izzy has cached for a specific user.")]
[Remarks("Izzy records at least 5 messages for each user, and will not throw away a message until it becomes irrelevant for spam pressure (see SpamPressureDecay, SpamMaxPressure and SpamBasePressure). Edits and deletes are ignored; only the original version of the message is cached. Restarting Izzy clears this cache.")]
[Remarks("Izzy caches at least 5 messages for each user, and will not throw away a message until it becomes irrelevant for spam pressure (see SpamPressureDecay, SpamMaxPressure and SpamBasePressure). Thus, this includes deleted messages that Izzy can't log in LogChannel because Discord doesn't produce a MessageDeleted event for them (e.g. deletions as part of a ban). Edits and deletes are ignored; only the original version of the message is cached. Restarting Izzy clears this cache.")]
[RequireContext(ContextType.Guild)]
[ModCommand(Group = "Permissions")]
[DevCommand(Group = "Permissions")]
Expand All @@ -869,6 +869,11 @@ public async Task RecentMessagesCommandAsync([Remainder] string user = "")
return;
}

if (!_state.RecentMessages.ContainsKey((ulong)userId))

Check notice

Code scanning / CodeQL

Inefficient use of ContainsKey Note

Inefficient use of 'ContainsKey' and
indexer
.
{
await ReplyAsync($"I haven't seen any messages from <@{userId}> since my last restart. Sorry.");
return;
}
var recentMessages = _state.RecentMessages[(ulong)userId];
if (recentMessages == null || recentMessages.Count == 0)
{
Expand Down

0 comments on commit ac70050

Please sign in to comment.