fix(bot): expose PKErrors from message edit proxy handler

This commit is contained in:
spiral 2022-12-29 01:34:50 +00:00
parent 3129f05b0f
commit c91349a1d6
No known key found for this signature in database
GPG Key ID: 244A11E4B0BCF40E

View File

@ -4,6 +4,7 @@ using Myriad.Cache;
using Myriad.Extensions; using Myriad.Extensions;
using Myriad.Gateway; using Myriad.Gateway;
using Myriad.Rest; using Myriad.Rest;
using Myriad.Rest.Types.Requests;
using Myriad.Types; using Myriad.Types;
using PluralKit.Core; using PluralKit.Core;
@ -76,6 +77,14 @@ public class MessageEdited: IEventHandler<MessageUpdateEvent>
} }
// Catch any failed proxy checks so they get ignored in the global error handler // Catch any failed proxy checks so they get ignored in the global error handler
catch (ProxyService.ProxyChecksFailedException) { } catch (ProxyService.ProxyChecksFailedException) { }
catch (PKError e)
{
// User-facing errors, print to the channel properly formatted
if (botPermissions.HasFlag(PermissionSet.SendMessages))
await _rest.CreateMessage(evt.ChannelId,
new MessageRequest { Content = $"{Emojis.Error} {e.Message}" });
}
} }
private async Task<MessageCreateEvent> GetMessageCreateEvent(MessageUpdateEvent evt, CachedMessage lastMessage, private async Task<MessageCreateEvent> GetMessageCreateEvent(MessageUpdateEvent evt, CachedMessage lastMessage,