mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
fix(bot): let you blacklist any channel you can proxy in
This commit is contained in:
parent
f37a6f4290
commit
d1dd4477d1
2 changed files with 5 additions and 24 deletions
|
|
@ -111,31 +111,10 @@ public class ProxyService
|
|||
return true;
|
||||
}
|
||||
|
||||
#pragma warning disable CA1822 // Mark members as static
|
||||
internal bool CanProxyInChannel(Channel ch, bool isRootChannel = false)
|
||||
#pragma warning restore CA1822 // Mark members as static
|
||||
{
|
||||
// this is explicitly selecting known channel types so that when Discord add new
|
||||
// ones, users don't get flooded with error codes if that new channel type doesn't
|
||||
// support a feature we need for proxying
|
||||
return ch.Type switch
|
||||
{
|
||||
Channel.ChannelType.GuildText => true,
|
||||
Channel.ChannelType.GuildPublicThread => true,
|
||||
Channel.ChannelType.GuildPrivateThread => true,
|
||||
Channel.ChannelType.GuildNews => true,
|
||||
Channel.ChannelType.GuildNewsThread => true,
|
||||
Channel.ChannelType.GuildVoice => true,
|
||||
Channel.ChannelType.GuildStageVoice => true,
|
||||
Channel.ChannelType.GuildForum => isRootChannel,
|
||||
Channel.ChannelType.GuildMedia => isRootChannel,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
// Proxy checks that give user errors
|
||||
public async Task<string> CanProxy(Channel channel, Channel rootChannel, Message msg, MessageContext ctx)
|
||||
{
|
||||
if (!(CanProxyInChannel(channel) && CanProxyInChannel(rootChannel, true)))
|
||||
if (DiscordUtils.IsValidGuildChannel(channel))
|
||||
return $"PluralKit cannot proxy messages in this type of channel.";
|
||||
|
||||
// Check if the message does not go over any Discord Nitro limits
|
||||
|
|
@ -159,6 +138,7 @@ public class ProxyService
|
|||
return null;
|
||||
}
|
||||
|
||||
// Proxy checks that don't give user errors unless `pk;debug proxy` is used
|
||||
public bool ShouldProxy(Channel channel, Channel rootChannel, Message msg, MessageContext ctx)
|
||||
{
|
||||
// Make sure author has a system
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue