@@ -205,7 +205,31 @@ static public function genModelModalSubmitData(DiscordInteractionData $data): Mo
205205 if ($ data ->components === null ){
206206 throw new AssertionError ("Components is null for modal submit data. " );
207207 }
208- return new ModalSubmitData ($ data ->custom_id , self ::genModelComponents ($ data ->components ->toArray ()));
208+ //Discord is a bit weird with components, so we have to do this.
209+ //top level is an ActionRow, we don't want that.
210+ $ components = [];
211+ //ActionRow $comp
212+ foreach ($ data ->components as $ comp ){
213+ if ($ comp ->type !== ComponentType::ACTION_ROW ->value ){
214+ throw new AssertionError ("Expected action row component, got {$ comp ->type }. " );
215+ }
216+ //Text Input $component
217+ foreach ($ comp ->components ?? [] as $ component ){
218+ if ($ component ->type !== ComponentType::TEXT_INPUT ->value ){
219+ throw new AssertionError ("Expected text input component, got {$ component ->type }. " );
220+ }
221+ if ($ component ->custom_id === null ){
222+ throw new AssertionError ("Custom id is null for text input component. " );
223+ }
224+ if ($ component ->value === null ){
225+ throw new AssertionError ("Value is null for text input component. " );
226+ }
227+ //TODO-Next-Major BREAKING: Discord doesnt send all data only value & custom_id
228+ $ components [] = new TextInput ($ component ->custom_id , TextInputStyle::SHORT , "" , 1 , 1 , false ,
229+ $ component ->value , null );
230+ }
231+ }
232+ return new ModalSubmitData ($ data ->custom_id , $ components );
209233 }
210234
211235 /**
0 commit comments