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:
parent
dd020d8aa8
commit
e620e30c10
@ -163,7 +163,7 @@ namespace PluralKit.Bot
|
|||||||
if (!ctx.Cache.TryGetChannel(id, out var channel))
|
if (!ctx.Cache.TryGetChannel(id, out var channel))
|
||||||
return Task.FromResult<Channel>(null);
|
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);
|
return Task.FromResult<Channel>(null);
|
||||||
|
|
||||||
ctx.PopArgument();
|
ctx.PopArgument();
|
||||||
|
@ -52,7 +52,7 @@ namespace PluralKit.Bot
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var channel = _cache.GetChannel(evt.ChannelId);
|
var channel = _cache.GetChannel(evt.ChannelId);
|
||||||
if (channel.Type != Channel.ChannelType.GuildText)
|
if (DiscordUtils.IsValidGuildChannel(channel))
|
||||||
return;
|
return;
|
||||||
var guild = _cache.GetGuild(channel.GuildId!.Value);
|
var guild = _cache.GetGuild(channel.GuildId!.Value);
|
||||||
var lastMessage = _lastMessageCache.GetLastMessage(evt.ChannelId);
|
var lastMessage = _lastMessageCache.GetLastMessage(evt.ChannelId);
|
||||||
|
@ -66,8 +66,8 @@ namespace PluralKit.Bot
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only proxies in guild text channels
|
// Proxied messages only exist in guild text channels, so skip checking if we're elsewhere
|
||||||
if (channel.Type != Channel.ChannelType.GuildText) return;
|
if (DiscordUtils.IsValidGuildChannel(channel)) return;
|
||||||
|
|
||||||
// Ignore reactions from bots (we can't DM them anyway)
|
// Ignore reactions from bots (we can't DM them anyway)
|
||||||
if (user.Bot) return;
|
if (user.Bot) return;
|
||||||
|
@ -91,7 +91,7 @@ namespace PluralKit.Bot
|
|||||||
if (ctx.SystemId == null) return false;
|
if (ctx.SystemId == null) return false;
|
||||||
|
|
||||||
// Make sure channel is a guild text channel and this is a normal message
|
// 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;
|
if (msg.Type != Message.MessageType.Default && msg.Type != Message.MessageType.Reply) return false;
|
||||||
|
|
||||||
// Make sure author is a normal user
|
// Make sure author is a normal user
|
||||||
|
@ -54,7 +54,7 @@ namespace PluralKit.Bot
|
|||||||
guildCount++;
|
guildCount++;
|
||||||
foreach (var channel in _cache.GetGuildChannels(guild.Id))
|
foreach (var channel in _cache.GetGuildChannels(guild.Id))
|
||||||
{
|
{
|
||||||
if (channel.Type == Channel.ChannelType.GuildText)
|
if (DiscordUtils.IsValidGuildChannel(channel))
|
||||||
channelCount++;
|
channelCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,5 +192,8 @@ namespace PluralKit.Bot
|
|||||||
var neededPermissions = PermissionSet.AddReactions | PermissionSet.ReadMessageHistory;
|
var neededPermissions = PermissionSet.AddReactions | PermissionSet.ReadMessageHistory;
|
||||||
return ((ctx.BotPermissions & neededPermissions) == neededPermissions);
|
return ((ctx.BotPermissions & neededPermissions) == neededPermissions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsValidGuildChannel(Channel channel) =>
|
||||||
|
channel.Type == Channel.ChannelType.GuildText || channel.Type == Channel.ChannelType.GuildNews;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user