From 9bfc593263a89fa9371475106f04e5c1f5c73e04 Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 2 Dec 2024 03:44:43 -0600 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20Add=20`MessageBuilder::getEmbed?= =?UTF-8?q?s()`=20and=20`MessageBuilder::getPoll()`=20=F0=9F=8E=A8=20Remov?= =?UTF-8?q?e=20duplicate=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 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..24acbe509 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 the embeds of the builder. + * + * @return Embed[] + */ + 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; } } From 90a4ce36410c16cee33c1a056c7b02e6b392b0db Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 2 Dec 2024 03:46:18 -0600 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=8E=A8=20Make=20docblock=20wording=20?= =?UTF-8?q?consistent=20with=20other=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Discord/Builders/MessageBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Discord/Builders/MessageBuilder.php b/src/Discord/Builders/MessageBuilder.php index 24acbe509..a00b9f535 100644 --- a/src/Discord/Builders/MessageBuilder.php +++ b/src/Discord/Builders/MessageBuilder.php @@ -329,7 +329,7 @@ public function setEmbeds(array $embeds): self } /** - * Returns the embeds of the builder. + * Returns all the embeds in the builder. * * @return Embed[] */ From 0f3c0f6c417e241e479aeee59f501e49431562eb Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 2 Dec 2024 04:00:25 -0600 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=8E=A8=20Update=20type=20for=20`getEm?= =?UTF-8?q?beds`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Discord/Builders/MessageBuilder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Discord/Builders/MessageBuilder.php b/src/Discord/Builders/MessageBuilder.php index a00b9f535..56617fb7d 100644 --- a/src/Discord/Builders/MessageBuilder.php +++ b/src/Discord/Builders/MessageBuilder.php @@ -331,9 +331,9 @@ public function setEmbeds(array $embeds): self /** * Returns all the embeds in the builder. * - * @return Embed[] + * @return array[]|null */ - public function getEmbeds(): array + public function getEmbeds(): ?array { return $this->embeds; }