-
Notifications
You must be signed in to change notification settings - Fork 46
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 array support for slash commands #340
Open
VelvetToroyashi
wants to merge
6
commits into
Remora:main
Choose a base branch
from
VelvetToroyashi:velvet/feat/variadic-slash-arguments
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add array support for slash commands #340
VelvetToroyashi
wants to merge
6
commits into
Remora:main
from
VelvetToroyashi:velvet/feat/variadic-slash-arguments
Commits on Sep 2, 2024
-
feat(commands)!: Add variadic slash command args
This commit changes how Remora.Discord.Commands maps slash commands, enabling support for arrays to be parsed and accepted, despite Discord STILL not having support for this. For better or worse, a snippet of code had to be removed: ```cs var collectionType = parameter.GetActualParameterType(); if (!collectionType.IsCollection() && !collectionType.IsArray) { // Sanity check throw new InvalidOperationException("Collection parameter was not a collection."); } ``` ^ For some reason, `.IsCollection()` returns...false? I gave up on trying to figure out why that was the case - the code still works fine and there's other validity checks elsewhere. BREAKING-CHANGE: Commands with the structure of `name__numbers` (e.g. `param__1`) are *no longer valid* and will get erased by the pre-parsing step that is a requisite to map arrays. This should be an absolutely niche case, but is still technically a breaking change, and should be documented as such. Some other things of note: - Attributes applied to the array apply to all elements in the array (this should go without saying, but hey) - `[Range]` controls the array's length; `Min` = required, `Max` = Length - If Min < Max, `Min` elements will be required and `Max - Min` elements will be optional. Max will coallecse to Min when unspecified. - Due to Discord's..questionable limitations, optional array parameters are placed at the end of the argument list for slash commands, but do preserve the order they're declared in relative to each other.
Configuration menu - View commit details
-
Copy full SHA for 445a56a - Browse repository at this point
Copy the full SHA 445a56aView commit details -
Configuration menu - View commit details
-
Copy full SHA for fb05a89 - Browse repository at this point
Copy the full SHA fb05a89View commit details
Commits on Sep 4, 2024
-
Configuration menu - View commit details
-
Copy full SHA for a0d7bc7 - Browse repository at this point
Copy the full SHA a0d7bc7View commit details -
Configuration menu - View commit details
-
Copy full SHA for dbf749d - Browse repository at this point
Copy the full SHA dbf749dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 8274f94 - Browse repository at this point
Copy the full SHA 8274f94View commit details -
Merge remote-tracking branch 'origin/velvet/feat/variadic-slash-argum…
…ents' into velvet/feat/variadic-slash-arguments
Configuration menu - View commit details
-
Copy full SHA for 1c82c91 - Browse repository at this point
Copy the full SHA 1c82c91View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.