Fix channel checks missing GuildNews

The log channel / logclean checks are left as-is; hopefully nobody is
using an announcements channel for their logs?
This commit is contained in:
spiral 2021-07-08 09:17:35 -04:00
parent dd020d8aa8
commit e620e30c10
No known key found for this signature in database
GPG Key ID: A6059F0CA0E1BD31
6 changed files with 9 additions and 6 deletions

View File

@ -163,7 +163,7 @@ namespace PluralKit.Bot
if (!ctx.Cache.TryGetChannel(id, out var channel))
return Task.FromResult<Channel>(null);
if (!(channel.Type == Channel.ChannelType.GuildText || channel.Type == Channel.ChannelType.GuildNews))
if (!DiscordUtils.IsValidGuildChannel(channel))
return Task.FromResult<Channel>(null);
ctx.PopArgument();

View File

@ -52,7 +52,7 @@ namespace PluralKit.Bot
return;
var channel = _cache.GetChannel(evt.ChannelId);
if (channel.Type != Channel.ChannelType.GuildText)
if (DiscordUtils.IsValidGuildChannel(channel))
return;
var guild = _cache.GetGuild(channel.GuildId!.Value);
var lastMessage = _lastMessageCache.GetLastMessage(evt.ChannelId);

View File

@ -66,8 +66,8 @@ namespace PluralKit.Bot
}
}
// Only proxies in guild text channels
if (channel.Type != Channel.ChannelType.GuildText) return;
// Proxied messages only exist in guild text channels, so skip checking if we're elsewhere
if (DiscordUtils.IsValidGuildChannel(channel)) return;
// Ignore reactions from bots (we can't DM them anyway)
if (user.Bot) return;

View File

@ -91,7 +91,7 @@ namespace PluralKit.Bot
if (ctx.SystemId == null) return false;
// Make sure channel is a guild text channel and this is a normal message
if (channel.Type != Channel.ChannelType.GuildText && channel.Type != Channel.ChannelType.GuildNews) return false;
if (DiscordUtils.IsValidGuildChannel(channel)) return false;
if (msg.Type != Message.MessageType.Default && msg.Type != Message.MessageType.Reply) return false;
// Make sure author is a normal user

View File

@ -54,7 +54,7 @@ namespace PluralKit.Bot
guildCount++;
foreach (var channel in _cache.GetGuildChannels(guild.Id))
{
if (channel.Type == Channel.ChannelType.GuildText)
if (DiscordUtils.IsValidGuildChannel(channel))
channelCount++;
}
}

View File

@ -192,5 +192,8 @@ namespace PluralKit.Bot
var neededPermissions = PermissionSet.AddReactions | PermissionSet.ReadMessageHistory;
return ((ctx.BotPermissions & neededPermissions) == neededPermissions);
}
public static bool IsValidGuildChannel(Channel channel) =>
channel.Type == Channel.ChannelType.GuildText || channel.Type == Channel.ChannelType.GuildNews;
}
}