CommandsNext: Attributes on subcommands aren't executing when no Command attribute is specified.
See original GitHub issueSummary
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
- Open up a DM.
- Execute
>>tag <string of choice>
- Notice that Hello World sent fine instead of throwing a NotAGuild error
- Execute
>>tag get <string of choice>
- Notice how the NotAGuild error was thrown this time.
- Execute
>>tag retrieve <string of choice>
- 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:
- Created 3 years ago
- Comments:10 (10 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No, it should not. GroupCommand marks an overload for a group. Any other attribute on it is invalid.
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!