Skip to content

Commit

Permalink
Handle string message type for respondWithMessage (#1199)
Browse files Browse the repository at this point in the history
Co-authored-by: Valithor Obsidion <valzargaming@gmail.com>
  • Loading branch information
Refaltor77 and valzargaming authored Feb 12, 2025
1 parent 5897e87 commit d97dc70
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Discord/Parts/Interactions/Interaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,16 @@ public function sendFollowUpMessage(MessageBuilder $builder, bool $ephemeral = f
*
* @return PromiseInterface
*/
public function respondWithMessage(MessageBuilder $builder, bool $ephemeral = false): PromiseInterface
public function respondWithMessage(MessageBuilder|string $builder, bool $ephemeral = false): PromiseInterface
{
if (! in_array($this->type, [self::TYPE_APPLICATION_COMMAND, self::TYPE_MESSAGE_COMPONENT, self::TYPE_MODAL_SUBMIT])) {
return reject(new \LogicException('You can only acknowledge application command, message component, or modal submit interactions.'));
}

if (is_string($builder)) {
$builder = MessageBuilder::new()->setContent($builder);
}

if ($ephemeral) {
$builder->setFlags(Message::FLAG_EPHEMERAL);
}
Expand Down

0 comments on commit d97dc70

Please sign in to comment.