$array * @return DiscordMessage */ public static function fromArray(array $array): DiscordMessage { return new DiscordMessage() ->setChannelId(Arr::get($array, self::ATTRIBUTE_CHANNEL_ID) ?? '0') ->setId(Arr::get($array, self::ATTRIBUTE_ID) ?? '0') ->setContent(Arr::get($array, self::ATTRIBUTE_CONTENT) ?? '') ->setEmbeds(Arr::map(Arr::get($array, self::ATTRIBUTE_EMBEDS) ?? [], fn (array $embed) => DiscordEmbed::fromArray($embed))) ->setImages(Arr::get($array, 'files') ?? Arr::get($array, self::ATTRIBUTE_IMAGES) ?? []); } /** * Get the channelId of the message. * * @return string */ public function getChannelId(): string { return $this->channelId; } /** * Get the id of the message. * * @return string */ public function getId(): string { return $this->id; } /** * Get the content of the message. * * @return string */ public function getContent(): string { return $this->content; } /** * Get the embeds of the message. * * @return array */ public function getEmbeds(): array { return $this->embeds; } /** * Get the images of the message. * * @return array */ public function getImages(): array { return $this->images; } /** * Set the content of the message. * * @param string $content * @return static */ public function setContent(string $content): static { $this->content = $content; return $this; } /** * Set the embeds of the message. * * @param array $embeds * @return static */ public function setEmbeds(array $embeds): static { $this->embeds = $embeds; return $this; } /** * Set the images of the message. * * @param array $images * @return static */ public function setImages(array $images): static { $this->images = $images; return $this; } /** * Set the channelId of the message. * * @param string $channelId * @return static */ public function setChannelId(string $channelId): static { $this->channelId = $channelId; return $this; } /** * Set the id of the message. * * @param string $id * @return static */ public function setId(string $id = '0'): static { $this->id = $id; return $this; } /** * Convert the constructor to an array. * * @return array */ public function toArray(): array { return [ 'channelId' => $this->getChannelId(), 'id' => $this->getId(), 'content' => $this->getContent(), 'embeds' => Arr::map($this->getEmbeds(), fn (DiscordEmbed $embed) => $embed->toArray()), 'files' => $this->getImages(), ]; } }