Skip to content

Commit 3996a76

Browse files
committed
#4 Testing and more errors
1 parent 378da00 commit 3996a76

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

src/DiscordWebhook/Webhook.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ public function send(): bool
6161
{
6262
/** @var ArrayCollection|int[] $responseCodes */
6363
$responseCodes = new ArrayCollection();
64+
65+
if ($this->getFile() !== null && $this->embeds->count() > 0) {
66+
throw new RuntimeException('Cannot use embeds and files in the same Webhook.');
67+
}
68+
6469
$payload = $this->payloadGenerator->generate($this);
6570

6671
$this->clients->forAll(function (int $key, Client $client) use ($payload, $responseCodes) {

tests/lipsum.pdf

68.4 KB
Binary file not shown.

tests/test.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,24 @@
2222

2323
$wh
2424
->setMessage('testtt')
25-
/*->addEmbed(
25+
->addEmbed(
2626
(new \DiscordWebhook\Embed())
27-
)*/;
27+
->setTitle('TEST')
28+
->setColor(\DiscordWebhook\EmbedColor::DARK_RED)
29+
->addField(
30+
(new \DiscordWebhook\Embed\Field())
31+
->setIsInline(true)
32+
->setName('TestFieldName')
33+
->setValue('TestFieldValue')
34+
)
35+
->setAuthor(
36+
(new \DiscordWebhook\Embed\Author())
37+
->setName('Scrummer')
38+
->setIconUrl('https://pbs.twimg.com/profile_images/1454563699587436557/KzhwN-fK_400x400.jpg')
39+
)
40+
)
41+
->setFile(new SplFileInfo(__DIR__ . '/lipsum.pdf'))
42+
;
2843

2944
$wh->send();
3045

0 commit comments

Comments
 (0)