From bb75519f6b7c447a008d58464a08d160d5a1c5dc Mon Sep 17 00:00:00 2001 From: Ske Date: Thu, 25 Jun 2020 09:14:05 +0200 Subject: [PATCH] Properly handle unauthorized log channel access --- PluralKit.Bot/Services/LogChannelService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PluralKit.Bot/Services/LogChannelService.cs b/PluralKit.Bot/Services/LogChannelService.cs index a949bb78..72ce12fd 100644 --- a/PluralKit.Bot/Services/LogChannelService.cs +++ b/PluralKit.Bot/Services/LogChannelService.cs @@ -1,3 +1,4 @@ +using System; using System.Threading.Tasks; using Dapper; @@ -53,9 +54,9 @@ namespace PluralKit.Bot { { return await _rest.GetChannelAsync(channel); } - catch (NotFoundException) + catch (Exception e) when (e is NotFoundException || e is UnauthorizedException) { - // Channel doesn't exist, let's remove it from the database too + // Channel doesn't exist or we don't have permission to access it, let's remove it from the database too _logger.Warning("Attempted to fetch missing log channel {LogChannel}, removing from database", channel); await using var conn = await _db.Obtain(); await conn.ExecuteAsync("update servers set log_channel = null where server = @Guild",