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.

CommandsNext: Attributes on subcommands aren't executing when no Command attribute is specified.

See original GitHub issue

Summary

All attributes, except for Command, Description, GroupCommand and Aliases, are not checked when a subcommand is being executed.

Details

Environment:

OS: Ubuntu 20.10
.NET Version: 5.0, Microsoft Snap Package, https://snapcraft.io/dotnet-sdk
Editor: Gnome Terminal, VSC + Omnisharp extension
Exceptions: None

CSProj file:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net5.0</TargetFramework>
        <RuntimeIdentifier>ubuntu.20.04-x64</RuntimeIdentifier>
        <RootNamespace>Tomoe</RootNamespace>
        <PublishTrimmed>true</PublishTrimmed>
        <PublishSingleFile>true</PublishSingleFile>
        <IncludeNativeLibrariesInSingleFile>true</IncludeNativeLibrariesInSingleFile>
        <IncludeSymbolsInSingleFile>true</IncludeSymbolsInSingleFile>
        <IncludeAllContentInSingleFile>true</IncludeAllContentInSingleFile>
        <NoWarn>CS8632;CS4014;CS1998</NoWarn>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="DSharpPlus" Version="4.0.0-nightly-00766" />
        <PackageReference Include="DSharpPlus.CommandsNext" Version="4.0.0-nightly-00766" />
        <PackageReference Include="DSharpPlus.Interactivity" Version="4.0.0-nightly-00766" />
        <PackageReference Include="Microsoft.Data.Sqlite" Version="3.1.9" />
        <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
        <PackageReference Include="Npgsql" Version="4.1.4" />
    </ItemGroup>
</Project>

Code:

namespace Tomoe.Commands.Public {
    [Group("tag")]
    public class Tags : BaseCommandModule {
        [RequireGuild]
        [Description("Gets a tag's content.")]
        [GroupCommand]
        [Command("get")]
        [Aliases("retrieve")]
        public async Task Get(CommandContext context, [RemainingText] string tagTitle) => context.RespondAsync("Hello world!");
    }
}

Steps to reproduce

  1. Open up a DM.
  2. Execute >>tag <string of choice>
  3. Notice that Hello World sent fine instead of throwing a NotAGuild error
  4. Execute >>tag get <string of choice>
  5. Notice how the NotAGuild error was thrown this time.
  6. Execute >>tag retrieve <string of choice>
  7. Notice how the NotAGuild error was thrown this time.

Workaround

Remove GroupCommand and use Command instead.

Notes

Issue of discovery was found on the DSharpPlus Discord: https://discord.com/channels/379378609942560770/379378610412191753/786982611946831902

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
Emzi0767commented, Dec 19, 2020

No, it should not. GroupCommand marks an overload for a group. Any other attribute on it is invalid.

0reactions
OoLunarcommented, Dec 19, 2020

You were correct. Again, I thank you for the support. I’ll see if I can write up an article later to clarify this. Have a wonderful day!

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: 'Client' object has no attribute 'command'
python 3. x - AttributeError: 'Client' object has no attribute 'command' - Stack Overflow.
Read more >
CommandsNext Introduction | DSharpPlus
Introduction to CommandsNext. This article will introduce you to some basic concepts of our native command framework: CommandsNext.
Read more >
Screen User's Manual
1 Overview. Screen is a full-screen window manager that multiplexes a physical terminal between several processes, typically interactive shells.
Read more >
Db2 Administration Tool User's Guide
This information provides instructions for customizing and using IBM Db2 Administration Tool for z/OS, a. Db2 catalog administration tool.
Read more >
StarTool FDM User's Guide
Select members whether or not a given character string is found, or not found, in the data. ▫. Change the load module attributes...
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