Skip to content

Commit

Permalink
✨ Add support for editing existing messages/interactions using `Messa…
Browse files Browse the repository at this point in the history
…ge::edit()` (#100)

🩹 Properly unset option emoji and descriptions use `null`
  • Loading branch information
Log1x authored Jun 24, 2024
1 parent 557bbba commit 204d5ba
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Discord/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 204d5ba

Please sign in to comment.