Tagging a non-group class with the Hidden attribute doesn't add the check to the commands.
See original GitHub issueSummary
When you add commands to a class that is not tagged as a command group (doesn’t have the Group attribute) and you add the Hidden attribute to it, then ‘command.IsHidden’ is FALSE for every command that doesn’t have the Hidden attribute set manually (add it to every method/command).
Adding it to every method (command) in the class is a valid workaround. But the RequireOwner Attribute is added as a pre-execution check for the command. For all the methods/commands in the class.
Example
namespace MyBestBotYet
{
[Hidden, RequireOwner]
class OwnerCommands
{
[Command("shutdown"), Aliases("exit")]
public async Task Shutdown(CommandContext ctx) // this command takes no arguments
{
//some super cool code
}
[Command("say"),Hidden]
public async Task Say(CommandContext ctx, [RemainingText, Description("What the bot will say.")] string sayStr)
{
//some even cooler code
}
}
In the example above the ‘say’ command will be hidden, but the shutdown command will NOT. Both commands however will be OwnerOnly.
Note
This issue was found during playing with the custom help formatter provided by emzi. The following line showed the issue. where toplevel is an IEnumerable of commands. IsHidden will be true for ‘say’ and false for ‘shutdown’ … var sxs = toplevel.Where(xc => !xc.IsHidden); … Command object during runtime: http://prntscr.com/hdwen1
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (5 by maintainers)
That’s what I keep asking for lmao
Checks are inherited, other attributes are not. Iunno, I’ll think about it.