Skip to content

Commit

Permalink
✨ Add MessageBuilder::getEmbeds() and MessageBuilder::getPoll() (#…
Browse files Browse the repository at this point in the history
…1265)

* ✨ Add `MessageBuilder::getEmbeds()` and `MessageBuilder::getPoll()`
🎨 Remove duplicate code

* 🎨 Make docblock wording consistent with other methods

* 🎨 Update type for `getEmbeds`
  • Loading branch information
Log1x authored Dec 2, 2024
1 parent 6db5275 commit 839a091
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions src/Discord/Builders/MessageBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 839a091

Please sign in to comment.