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)
|
public async Task PermCheckGuild(Context ctx)
|
||||||
{
|
{
|
||||||
var guildIdStr = ctx.PopArgument() ?? throw new PKSyntaxError("You must pass a server ID.");
|
IGuild guild;
|
||||||
if (!ulong.TryParse(guildIdStr, out var guildId)) throw new PKSyntaxError($"Could not parse `{guildIdStr.SanitizeMentions()}` as an ID.");
|
|
||||||
|
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?
|
// 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)
|
if (guild == null)
|
||||||
throw Errors.GuildNotFound(guildId);
|
throw Errors.GuildNotFound(guildId);
|
||||||
|
}
|
||||||
|
|
||||||
var requiredPermissions = new []
|
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.ManageMessages,
|
||||||
ChannelPermission.ManageWebhooks
|
ChannelPermission.ManageWebhooks
|
||||||
};
|
};
|
||||||
@ -116,7 +130,7 @@ namespace PluralKit.Bot.Commands {
|
|||||||
var channelsList = string.Join("\n", channels
|
var channelsList = string.Join("\n", channels
|
||||||
.OrderBy(c => c.Position)
|
.OrderBy(c => c.Position)
|
||||||
.Select(c => $"#{c.Name}"));
|
.Select(c => $"#{c.Name}"));
|
||||||
eb.AddField($"Missing *{missingPermissionNames}*", channelsList);
|
eb.AddField($"Missing *{missingPermissionNames}*", channelsList.Truncate(1000));
|
||||||
eb.WithColor(Color.Red);
|
eb.WithColor(Color.Red);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user