Fix PermCheck permissions and no-guild invocation syntax
This commit is contained in:
parent
523469e5e6
commit
4e98a51363
@ -58,17 +58,31 @@ namespace PluralKit.Bot.Commands {
|
||||
|
||||
public async Task PermCheckGuild(Context ctx)
|
||||
{
|
||||
var guildIdStr = ctx.PopArgument() ?? throw new PKSyntaxError("You must pass a server ID.");
|
||||
if (!ulong.TryParse(guildIdStr, out var guildId)) throw new PKSyntaxError($"Could not parse `{guildIdStr.SanitizeMentions()}` as an ID.");
|
||||
IGuild guild;
|
||||
|
||||
if (ctx.Guild != null && !ctx.HasNext())
|
||||
{
|
||||
guild = ctx.Guild;
|
||||
}
|
||||
else
|
||||
{
|
||||
var guildIdStr = ctx.RemainderOrNull() ?? throw new PKSyntaxError("You must pass a server ID or run this command as .");
|
||||
if (!ulong.TryParse(guildIdStr, out var guildId))
|
||||
throw new PKSyntaxError($"Could not parse `{guildIdStr.SanitizeMentions()}` as an ID.");
|
||||
|
||||
// TODO: will this call break for sharding if you try to request a guild on a different bot instance?
|
||||
var guild = ctx.Client.GetGuild(guildId) as IGuild;
|
||||
guild = ctx.Client.GetGuild(guildId);
|
||||
if (guild == null)
|
||||
throw Errors.GuildNotFound(guildId);
|
||||
}
|
||||
|
||||
var requiredPermissions = new []
|
||||
{
|
||||
ChannelPermission.ViewChannel, // Manage Messages automatically grants Send and Add Reactions, but not Read
|
||||
ChannelPermission.ViewChannel,
|
||||
ChannelPermission.SendMessages,
|
||||
ChannelPermission.AddReactions,
|
||||
ChannelPermission.AttachFiles,
|
||||
ChannelPermission.EmbedLinks,
|
||||
ChannelPermission.ManageMessages,
|
||||
ChannelPermission.ManageWebhooks
|
||||
};
|
||||
@ -116,7 +130,7 @@ namespace PluralKit.Bot.Commands {
|
||||
var channelsList = string.Join("\n", channels
|
||||
.OrderBy(c => c.Position)
|
||||
.Select(c => $"#{c.Name}"));
|
||||
eb.AddField($"Missing *{missingPermissionNames}*", channelsList);
|
||||
eb.AddField($"Missing *{missingPermissionNames}*", channelsList.Truncate(1000));
|
||||
eb.WithColor(Color.Red);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user