fix: unbreak error reporting for @mention prefix

This commit is contained in:
spiral 2022-01-14 15:05:46 -05:00
parent 47e15e3acb
commit d58cc216c0
No known key found for this signature in database
GPG Key ID: A6059F0CA0E1BD31
3 changed files with 5 additions and 6 deletions

View File

@ -220,7 +220,8 @@ public class Bot
return;
// Once we've sent it to Sentry, report it to the user (if we have permission to)
var reportChannel = handler.ErrorChannelFor(evt);
var ourUserId = await _cache.GetOwnUser();
var reportChannel = handler.ErrorChannelFor(evt, ourUserId);
if (reportChannel == null)
return;

View File

@ -6,5 +6,5 @@ public interface IEventHandler<in T> where T : IGatewayEvent
{
Task Handle(Shard shard, T evt);
ulong? ErrorChannelFor(T evt) => null;
ulong? ErrorChannelFor(T evt, ulong userId) => null;
}

View File

@ -51,11 +51,9 @@ public class MessageCreated: IEventHandler<MessageCreateEvent>
}
// for now, only return error messages for explicit commands
public ulong? ErrorChannelFor(MessageCreateEvent evt)
public ulong? ErrorChannelFor(MessageCreateEvent evt, ulong userId)
{
// todo: fix @mention prefix
// it only breaks error reporting so I'm not *too* worried about it, but should be fixed eventually
if (!HasCommandPrefix(evt.Content, default, out var cmdStart) || cmdStart == evt.Content.Length)
if (!HasCommandPrefix(evt.Content, userId, out var cmdStart) || cmdStart == evt.Content.Length)
return null;
return evt.ChannelId;