diff --git a/src/Discord/Message.php b/src/Discord/Message.php index 899235c..847733f 100644 --- a/src/Discord/Message.php +++ b/src/Discord/Message.php @@ -214,7 +214,9 @@ public function build(): MessageBuilder } if ($this->hasButtons()) { - $message->addComponent($this->getButtons()); + foreach ($this->getButtons() as $button) { + $message->addComponent($button); + } } if ($this->hasFiles()) { @@ -407,21 +409,23 @@ public function getComponents(): array } /** - * Get the buttons. + * Get the button components. */ - public function getButtons() + public function getButtons(): array { if (! $this->hasButtons()) { - return; + return []; } - $buttons = ActionRow::new(); + return collect($this->buttons)->chunk(5)->map(function ($buttons) { + $row = ActionRow::new(); - foreach ($this->buttons as $button) { - $buttons->addComponent($button); - } + foreach ($buttons as $button) { + $row->addComponent($button); + } - return $buttons; + return $row; + })->all(); } /**