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 3ce0fa4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions 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,9 +869,10 @@ public async Task RecentMessagesCommandAsync([Remainder] string user = "")
return;
}

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

0 comments on commit 3ce0fa4

Please sign in to comment.