question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tagging a non-group class with the Hidden attribute doesn't add the check to the commands.

See original GitHub issue

Summary

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:closed
  • Created 6 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
moonPtrcommented, Nov 22, 2017

That’s what I keep asking for lmao

0reactions
Emzi0767commented, Nov 23, 2017

Checks are inherited, other attributes are not. Iunno, I’ll think about it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Proper use 'hidden' attribute in html tag
In this case <div class="myclass" hidden> you are using a global HTML attribute, which will make browsers won't render the element.
Read more >
Labeling basics—ArcGIS Pro | Documentation
Press Ctrl while clicking to check or uncheck labeling visibility for all layers or label classes simultaneously. Access the basic labeling properties on...
Read more >
Robots Meta Tags Specifications | Google Search Central
Learn how to add robots meta tags and read how page and text-level settings can be used to adjust how Google presents your...
Read more >
Edit document structure with the Content and Tags panels ...
First consider using the Add Tags To Document command. View tags in the Tags panel. Choose View > Show/Hide > ...
Read more >
Code completion | WebStorm Documentation
Basic code completion helps you complete the names of classes, methods, ... WebStorm will use the file content (tag and attribute names and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found