Skip to content

Commit

Permalink
Various message component bug fixes (#535)
Browse files Browse the repository at this point in the history
* add label and action rows to models (correct formatting)

* change nullability of TextInputComponent fields to hold component from ModalSubmitInteraction

* Use maybeParse for style field

Co-authored-by: Rapougnac <[email protected]>

* change ModalBuilder components to ActionRowBuilders

---------

Co-authored-by: Rapougnac <[email protected]>
  • Loading branch information
jr1221 and Lexedia authored Sep 20, 2023
1 parent 344b86c commit d130e4c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/src/builders/interaction_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class ModalBuilder extends CreateBuilder<ModalBuilder> {

String title;

List<TextInputBuilder> components;
List<ActionRowBuilder> components;

ModalBuilder({required this.customId, required this.title, required this.components});

Expand Down
1 change: 1 addition & 0 deletions lib/src/builders/message/component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ class TextInputBuilder extends MessageComponentBuilder {
...super.build(),
'custom_id': customId,
'style': style.value,
'label': label,
if (minLength != null) 'min_length': minLength,
if (maxLength != null) 'max_length': maxLength,
if (isRequired != null) 'required': isRequired,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/http/managers/message_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ class MessageManager extends Manager<Message> {
),
MessageComponentType.textInput => TextInputComponent(
customId: raw['custom_id'] as String,
style: TextInputStyle.parse(raw['style'] as int),
label: raw['label'] as String,
style: maybeParse(raw['style'], TextInputStyle.parse),
label: raw['label'] as String?,
minLength: raw['min_length'] as int?,
maxLength: raw['max_length'] as int?,
isRequired: raw['required'] as bool?,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/models/message/component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ class TextInputComponent extends MessageComponent {

final String customId;

final TextInputStyle style;
final TextInputStyle? style;

final String label;
final String? label;

final int? minLength;

Expand Down

0 comments on commit d130e4c

Please sign in to comment.