From 204d5ba0cacca36e9e3c35d95dec904f592666d7 Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 24 Jun 2024 06:14:47 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20support=20for=20editing=20exi?= =?UTF-8?q?sting=20messages/interactions=20using=20`Message::edit()`=20(#1?= =?UTF-8?q?00)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🩹 Properly unset option emoji and descriptions use `null` --- src/Discord/Message.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Discord/Message.php b/src/Discord/Message.php index 74505ab..da42d5d 100644 --- a/src/Discord/Message.php +++ b/src/Discord/Message.php @@ -340,6 +340,18 @@ public function reply(Interaction|ChannelMessage $message, bool $ephemeral = fal return $message->reply($this->build()); } + /** + * Edit an existing message or interaction message. + */ + public function edit(Interaction|ChannelMessage $message): ExtendedPromiseInterface + { + if ($message instanceof Interaction) { + return $message->updateMessage($this->build()); + } + + return $message->edit($this->build()); + } + /** * Get the embed. */ @@ -866,8 +878,8 @@ public function select( } $option = Option::new($value['label'] ?? $key, $value['value'] ?? $key) - ->setDescription($value['description'] ?? '') - ->setEmoji($value['emoji'] ?? '') + ->setDescription($value['description'] ?? null) + ->setEmoji($value['emoji'] ?? null) ->setDefault($value['default'] ?? false); $select->addOption($option);