Skip to content

Commit

Permalink
✨ Add MessageBuilder::getEmbeds() and MessageBuilder::getPoll()
Browse files Browse the repository at this point in the history
🎨 Remove duplicate code
  • Loading branch information
Log1x committed Dec 2, 2024
1 parent 6db5275 commit 9bfc593
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 the embeds of the builder.
*
* @return Embed[]
*/
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 9bfc593

Please sign in to comment.