-
-
Notifications
You must be signed in to change notification settings - Fork 133
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
feat(validate, http)!: validate command and options names #1395
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
baptiste0928
added
t-feature
Addition of a new feature
c-http
Affects the http crate
m-breaking change
Breaks the public API.
f-application-commands
c-validate
Affects the validate crate
labels
Dec 28, 2021
7596ff
suggested changes
Dec 28, 2021
7596ff
suggested changes
Jan 7, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couple things. looks good so far.
http/src/request/application/command/create_global_command/mod.rs
Outdated
Show resolved
Hide resolved
http/src/request/application/command/create_guild_command/chat_input.rs
Outdated
Show resolved
Hide resolved
7596ff
suggested changes
Jan 7, 2022
http/src/request/application/command/create_global_command/mod.rs
Outdated
Show resolved
Hide resolved
7596ff
reviewed
Jan 7, 2022
http/src/request/application/command/create_global_command/chat_input.rs
Outdated
Show resolved
Hide resolved
7596ff
approved these changes
Jan 7, 2022
Erk-
approved these changes
Jan 10, 2022
7596ff
added a commit
that referenced
this pull request
Jan 23, 2022
Validation Validation has been moved to a new crate, `twilight_validate` ([#1331] - [@7596ff]). Similar concerns such as creating messages (`MessageValidationError`) or editing channels (`ChannelValidationError`) have been grouped together in error types, and these error types replace the custom error types associated with each request builder. Miscellaneous validation functions that were associated things like get user limits are also placed under one error type, `ValidationError`. The following error types are now returned by the following methods: - `ChannelValidationError` - `Client::create_guild_channel` - `Client::create_thread_from_message` - `Client::create_thread` - `CreateGuildChannel::rate_limit_per_user` - `CreateGuildChannel::topic` - `UpdateChannel::name` - `UpdateChannel::rate_limit_per_user` - `UpdateChannel::topic` - `UpdateThread::name` - `UpdateThread::rate_limit_per_user` - `CommandValidationError` - `InteractionClient::set_command_permissions` - `InteractionClient::update_command_permissions` - `MessageValidationError` - `CreateFollowupMessage::components` - `CreateMessage::components` - `CreateMessage::content` - `CreateMessage::embeds` - `CreateMessage::stickers` - `CreateWebhookMessage::components` - `UpdateFollowupMessage::components` - `UpdateFollowupMessage::content` - `UpdateFollowupMessage::embeds` - `UpdateMessage::components` - `UpdateMessage::content` - `UpdateMessage::embeds` - `UpdateOriginalResponse::components` - `UpdateOriginalResponse::content` - `UpdateOriginalResponse::embeds` - `UpdateWebhookMessage::components` - `UpdateWebhookMessage::content` - `UpdateWebhookMessage::embeds` - `ValidationError` - `AddGuildMember::nick` - `Client::create_guild_from_template` - `Client::create_stage_instance` - `Client::create_template` - `CreateBan::delete_message_days` - `CreateGuildPrune::days` - `CreateInvite::max_uses` - `CreateTemplate::description` - `GetChannelMessages::limit` - `GetCurrentUserGuilds::limit` - `GetGuildAuditLog::limit` - `GetGuildMembers::limit` - `GetGuildPruneCount::limit` - `GetReactions::limit` - `SearchGuildMembers::limit` - `UpdateCurrentMember::nick` - `UpdateCurrentUser::username` - `UpdateGuild::name` - `UpdateGuildMember::communication_disabled_until` - `UpdateGuildMember::nick` - `UpdateStageInstance::topic` - `UpdateTemplate::description` - `UpdateTemplate::name` The following functions now perform validation: - `MessageValidationError` - `CreateFollowupMessage::content` - `CreateFollowupMessage::embeds` - `CreateWebhookMessage::content` - `CreateWebhookMessage::embeds` Additions Add a sealed trait located at `request::TryIntoRequest` for converting a typed request builder into a raw `request::Request` ([#1162] - [@zeylahellyer]). This allows users to inspect requests prior to sending them which may be useful for debugging and unit testing. Support guild scheduled events ([#1347] - [@7596ff]). Adds the following methods: `Client::create_guild_scheduled_event`, `Client::delete_guild_scheduled_event`, `Client::guild_scheduled_event_users`, `Client::guild_scheduled_event`, `Client::guild_scheduled_events`, `Client::update_guild_scheduled_event`. Changes All types and method signatures have been updated to use the new `Id<T>` syntax ([#1260] - [@zeylahellyer]). Requests requiring an `Id<ApplicationMarker>` are now created through an `InteractionClient` ([#1275] - [@zeylahellyer]]). This is created by passing the ID to `Client::interaction`. It replaces `set_application_id`. The interaction methods are no longer on `Client`. The `rustls` feature has been removed ([#1314] - [@Gelbpunkt]). Users must manually select one of `rustls-native-roots` or `rustls-webpki-roots`. The `ErrorCode` which contained custom names and descriptions for each API error code has been removed ([#1394] - [@zeylahellyer]). Users can now read `GeneralApiError::code: u64` to see the code. `InteractionClient::{create_global_command, create_guild_command}` no longer accept a `name` when first creating the request ([#1395] - [@baptiste0928]). Instead, depending on the type of command the user is created, different validation is performed. For `ChatInput` commands, validation ensures that the name is between 1 and 32 characters in length and that it contains no uppercase letters. For `Message` and `User` commands, validation only ensures the length is correct. Similar validation is performed on `ChatInput` `option`s. `Route` now directly implements `Display` ([#1397] - [@vilgotf]). The MSRV has been updated to 1.57 ([#1402] - [@zeylahellyer]). The Rust edition has been updated to 2021 ([#1412] - [@vilgotf]). `RequestReactionType` now directly implements `Display` ([#1457] - [@vilgotf]). [#1162]: #1162 [#1260]: #1260 [#1275]: #1275 [#1314]: #1314 [#1331]: #1331 [#1394]: #1394 [#1395]: #1395 [#1402]: #1402 [#1412]: #1412 [#1457]: #1457 [@7596ff]: https://github.com/7596ff [@baptiste0928]: https://github.com/baptiste0928 [@Gelbpunkt]: https://github.com/Gelbpunkt [@vilgotf]: https://github.com/vilgotf [@zeylahellyer]: https://github.com/zeylahellyer
7596ff
added a commit
that referenced
this pull request
Jan 23, 2022
Initial release ([#1331], [#1395] - [@7596ff], [@baptiste0928]). [#1331]: #1331 [#1395]: #1395 [@7596ff]: https://github.com/7596ff [@baptiste0928]: https://github.com/baptiste0928
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
c-http
Affects the http crate
c-validate
Affects the validate crate
m-breaking change
Breaks the public API.
t-feature
Addition of a new feature
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.
This PR improves validation of slash command names and command options names. It checks that chat input command names and options names does not contain non-alphanumeric characters nor uppercase characters.
As the validation depend on the command type, the name is no longer validated in
create_guild_command
orcreate_global_command
methods. The validation has been moved tochat_input
,user
andmessage
methods.