@@ -47,6 +47,44 @@ abstract class Component implements JsonSerializable
4747 /** @deprecated 7.4.0 Use `Component::TYPE_STRING_SELECT` */
4848 public const TYPE_SELECT_MENU = 3 ;
4949
50+ public const TYPE_CLASSES = [
51+ self ::TYPE_ACTION_ROW => ActionRow::class,
52+ self ::TYPE_BUTTON => Button::class,
53+ self ::TYPE_STRING_SELECT => StringSelect::class,
54+ self ::TYPE_TEXT_INPUT => TextInput::class,
55+ self ::TYPE_USER_SELECT => UserSelect::class,
56+ self ::TYPE_ROLE_SELECT => RoleSelect::class,
57+ self ::TYPE_MENTIONABLE_SELECT => MentionableSelect::class,
58+ self ::TYPE_CHANNEL_SELECT => ChannelSelect::class,
59+ self ::TYPE_SECTION => Section::class,
60+ self ::TYPE_TEXT_DISPLAY => TextDisplay::class,
61+ self ::TYPE_THUMBNAIL => Thumbnail::class,
62+ self ::TYPE_MEDIA_GALLERY => MediaGallery::class,
63+ self ::TYPE_FILE => File::class,
64+ self ::TYPE_SEPARATOR => Separator::class,
65+ self ::TYPE_CONTAINER => Container::class
66+ ];
67+
68+
69+ /**
70+ * Fills the properties of the current object with values from the provided associative array.
71+ *
72+ * Iterates over each key-value pair in the input array and assigns the value to the corresponding
73+ * property of the object if the property exists.
74+ *
75+ * @param array $data
76+ *
77+ * @return void
78+ */
79+ public function fill (array $ data ): void
80+ {
81+ foreach ($ data as $ key => $ value ) {
82+ if (property_exists ($ this , $ key )) {
83+ $ this ->{$ key } = $ value ;
84+ }
85+ }
86+ }
87+
5088 /**
5189 * Generates a UUID which can be used for component custom IDs.
5290 *
0 commit comments