From 839a091042777ffc36a447f473b39e78625d981a Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 2 Dec 2024 06:34:07 -0600 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20`MessageBuilder::getEmbeds()`?= =?UTF-8?q?=20and=20`MessageBuilder::getPoll()`=20(#1265)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ Add `MessageBuilder::getEmbeds()` and `MessageBuilder::getPoll()` 🎨 Remove duplicate code * 🎨 Make docblock wording consistent with other methods * 🎨 Update type for `getEmbeds` --- src/Discord/Builders/MessageBuilder.php | 28 ++++++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/Discord/Builders/MessageBuilder.php b/src/Discord/Builders/MessageBuilder.php index 4566b6508..56617fb7d 100644 --- a/src/Discord/Builders/MessageBuilder.php +++ b/src/Discord/Builders/MessageBuilder.php @@ -220,6 +220,16 @@ public function setPoll(Poll|null $poll): self return $this; } + /** + * Returns the poll of the message. + * + * @return Poll|null + */ + public function getPoll(): ?Poll + { + return $this->poll; + } + /** * Override the default username of the webhook. Only used for executing webhook. * @@ -318,6 +328,16 @@ public function setEmbeds(array $embeds): self return $this->addEmbed(...$embeds); } + /** + * Returns all the embeds in the builder. + * + * @return array[]|null + */ + public function getEmbeds(): ?array + { + return $this->embeds; + } + /** * Sets the allowed mentions object of the message. * @@ -750,14 +770,6 @@ public function jsonSerialize(): ?array $body['poll'] = $this->poll; } - if (isset($this->enforce_nonce)) { - $body['enforce_nonce'] = $this->enforce_nonce; - } - - if (isset($this->poll)) { - $body['poll'] = $this->poll; - } - return $body; } }