mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
.h command show now properly show both channel and server user permission requirements
This commit is contained in:
@@ -3,7 +3,7 @@ using NadekoBot.Modules.Administration.Services;
|
|||||||
|
|
||||||
namespace Discord;
|
namespace Discord;
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.Method)]
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
|
||||||
public class UserPermAttribute : RequireUserPermissionAttribute
|
public class UserPermAttribute : RequireUserPermissionAttribute
|
||||||
{
|
{
|
||||||
public UserPermAttribute(GuildPerm permission)
|
public UserPermAttribute(GuildPerm permission)
|
||||||
|
@@ -152,18 +152,22 @@ public class HelpService : IExecNoCommand, INService
|
|||||||
.Any(x => x is OnlyPublicBotAttribute))
|
.Any(x => x is OnlyPublicBotAttribute))
|
||||||
toReturn.Add("Only Public Bot");
|
toReturn.Add("Only Public Bot");
|
||||||
|
|
||||||
var userPerm = (UserPermAttribute)cmd.Preconditions.FirstOrDefault(ca => ca is UserPermAttribute);
|
var userPermString = cmd.Preconditions
|
||||||
|
.Where(ca => ca is UserPermAttribute)
|
||||||
|
.Cast<UserPermAttribute>()
|
||||||
|
.Select(userPerm =>
|
||||||
|
{
|
||||||
|
if (userPerm.ChannelPermission is { } cPerm)
|
||||||
|
return GetPreconditionString(cPerm);
|
||||||
|
|
||||||
var userPermString = string.Empty;
|
if (userPerm.GuildPermission is { } gPerm)
|
||||||
if (userPerm is not null)
|
return GetPreconditionString(gPerm);
|
||||||
{
|
|
||||||
if (userPerm.ChannelPermission is { } cPerm)
|
|
||||||
userPermString = GetPreconditionString(cPerm);
|
|
||||||
|
|
||||||
if (userPerm.GuildPermission is { } gPerm)
|
|
||||||
userPermString = GetPreconditionString(gPerm);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
})
|
||||||
|
.Where(x => !string.IsNullOrWhiteSpace(x))
|
||||||
|
.Join('\n');
|
||||||
|
|
||||||
if (overrides is null)
|
if (overrides is null)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(userPermString))
|
if (!string.IsNullOrWhiteSpace(userPermString))
|
||||||
|
Reference in New Issue
Block a user