Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to invoke a command specifying optional values by name #1123

Merged
merged 12 commits into from Nov 6, 2018

Conversation

Joe4evr
Copy link
Contributor

@Joe4evr Joe4evr commented Aug 9, 2018

Requires:

  • 1 (one) POCO to hold argument values (Application of the attribute automatically sets IsRemainder for that parameter)
  • All properties in the POCO are an optional parameter (Required parameters should be specified before the POCO parameter)
  • When invoking, parameters need to be a single word, ending with a colon (:); arguments need to be either a single word or wrapped in quotes
  • Supports reading into an IEnumerable<T> property; user's input needs to be comma-separated

@Joe4evr
Copy link
Contributor Author

Joe4evr commented Aug 18, 2018

Just had another thought, should we make it such that at least one property needs to be specified in order to make the typeread succeed by default? I'm thinking we could allow modifying that behavior by whether the parameter itself has a default value (= null).

@Joe4evr
Copy link
Contributor Author

Joe4evr commented Aug 18, 2018

Okay, so I just worked on what that would look like...

aaaaaaaaaaaaaaaaaaand it requires breaking the signature of ReadAsync for that to work.

Now, we're technically still in beta, so it's not strictly speaking a problem, but we do have a good number of people on the nightlies, so I wanted to get some input before I push it.

Turns out it doesn't need to break after all. Okay then!

namespace Discord.Commands
{
/// <summary>
/// Instructs the command system to treat command paramters of this type

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Instructs the command system to treat command paramters of this type
/// Instructs the command system to treat command parameters of this type

@@ -3,6 +3,7 @@
<OutputType>Exe</OutputType>
<RootNamespace>Discord</RootNamespace>
<TargetFramework>netcoreapp1.1</TargetFramework>
<DebugType>portable</DebugType>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be here?

@foxbot foxbot merged commit 419c0a5 into discord-net:dev Nov 6, 2018
@Joe4evr Joe4evr deleted the NamedArgs branch October 5, 2019 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants