From d130e4c502acf5c0f8f726c18310f16060310d25 Mon Sep 17 00:00:00 2001 From: Jack Rubacha Date: Wed, 20 Sep 2023 02:01:24 -0400 Subject: [PATCH] Various message component bug fixes (#535) * 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 * change ModalBuilder components to ActionRowBuilders --------- Co-authored-by: Rapougnac --- lib/src/builders/interaction_response.dart | 2 +- lib/src/builders/message/component.dart | 1 + lib/src/http/managers/message_manager.dart | 4 ++-- lib/src/models/message/component.dart | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/src/builders/interaction_response.dart b/lib/src/builders/interaction_response.dart index be130ff26..7cf4605b2 100644 --- a/lib/src/builders/interaction_response.dart +++ b/lib/src/builders/interaction_response.dart @@ -120,7 +120,7 @@ class ModalBuilder extends CreateBuilder { String title; - List components; + List components; ModalBuilder({required this.customId, required this.title, required this.components}); diff --git a/lib/src/builders/message/component.dart b/lib/src/builders/message/component.dart index 4b3aaa16d..c47640535 100644 --- a/lib/src/builders/message/component.dart +++ b/lib/src/builders/message/component.dart @@ -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, diff --git a/lib/src/http/managers/message_manager.dart b/lib/src/http/managers/message_manager.dart index f2b0c83e1..62730fea4 100644 --- a/lib/src/http/managers/message_manager.dart +++ b/lib/src/http/managers/message_manager.dart @@ -236,8 +236,8 @@ class MessageManager extends Manager { ), 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?, diff --git a/lib/src/models/message/component.dart b/lib/src/models/message/component.dart index 746ebe9a7..3b6ab40d2 100644 --- a/lib/src/models/message/component.dart +++ b/lib/src/models/message/component.dart @@ -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;