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
|
|
@ -204,7 +204,8 @@ public class ServerConfig
|
||||||
var affectedChannels = new List<Channel>();
|
var affectedChannels = new List<Channel>();
|
||||||
if (ctx.Match("all"))
|
if (ctx.Match("all"))
|
||||||
affectedChannels = (await _cache.GetGuildChannels(ctx.Guild.Id))
|
affectedChannels = (await _cache.GetGuildChannels(ctx.Guild.Id))
|
||||||
.Where(x => x.Type == Channel.ChannelType.GuildText).ToList();
|
// All the channel types you can proxy in
|
||||||
|
.Where(x => DiscordUtils.IsValidGuildChannel(x)).ToList();
|
||||||
else if (!ctx.HasNext()) throw new PKSyntaxError("You must pass one or more #channels.");
|
else if (!ctx.HasNext()) throw new PKSyntaxError("You must pass one or more #channels.");
|
||||||
else
|
else
|
||||||
while (ctx.HasNext())
|
while (ctx.HasNext())
|
||||||
|
|
|
||||||
|
|
@ -111,31 +111,10 @@ public class ProxyService
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable CA1822 // Mark members as static
|
// Proxy checks that give user errors
|
||||||
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,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<string> CanProxy(Channel channel, Channel rootChannel, Message msg, MessageContext ctx)
|
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.";
|
return $"PluralKit cannot proxy messages in this type of channel.";
|
||||||
|
|
||||||
// Check if the message does not go over any Discord Nitro limits
|
// Check if the message does not go over any Discord Nitro limits
|
||||||
|
|
@ -159,6 +138,7 @@ public class ProxyService
|
||||||
return null;
|
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)
|
public bool ShouldProxy(Channel channel, Channel rootChannel, Message msg, MessageContext ctx)
|
||||||
{
|
{
|
||||||
// Make sure author has a system
|
// Make sure author has a system
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue