discord-php / DiscordPHP

An API to interact with the popular messaging app Discord
MIT License
985 stars 236 forks source link

Reply to a user with attachments #1083

Closed CatAnonymous closed 1 year ago

CatAnonymous commented 1 year ago

I'm trying to send a message with attachments

According to a document I found, but it doesn't seem to work

$attachments[] = [
      "file" => 'URL/file path'
    ];
$message->reply("Hello, this message contains multiple attachments:", false, $attachments);
FoxWorn3365 commented 1 year ago

Have you tried to use the MessageBuilder?

CatAnonymous commented 1 year ago

Have you tried to use the MessageBuilder? thanks, it worked fine

$messageBuilder = MessageBuilder::new();
$messageBuilder->setContent('hello, world!');

foreach($images as $image) {
  $messageBuilder->addFile($image, 'file.png');
}

//$message->channel->sendMessage($messageBuilder);

$message->reply($messageBuilder);