Skip to content

Commit

Permalink
Add enforce nonce to message builder (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
Exanlv committed Apr 23, 2024
1 parent 46ff7aa commit 25855f8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src/Rest/Helpers/Channel/MessageBuilder.php
Expand Up @@ -48,6 +48,18 @@ public function getNonce(): ?string
return $this->data['nonce'] ?? null;
}

public function setEnforceNonce(bool $enforceNonce)
{
$this->data['enforce_nonce'] = $enforceNonce;

return $this;
}

public function getEnforceNonce(): ?bool
{
return $this->data['enforce_nonce'] ?? null;
}

public function setTts(bool $tts): self
{
$this->data['tts'] = $tts;
Expand Down
6 changes: 3 additions & 3 deletions tests/Command/GuildCommandExtensionTest.php
Expand Up @@ -27,7 +27,7 @@ protected function setUp(): void

public function testItEmitsEventsForApplicationCommands()
{
$extension = new GuildCommandExtension(null, '::guild id::');
$extension = new GuildCommandExtension('::guild id::');
$extension->initialize($this->discord);

$hasRun = [false, false, false];
Expand Down Expand Up @@ -69,7 +69,7 @@ public function testItEmitsEventsForApplicationCommands()

public function testItDoesNotEmitEventsForDifferentGuilds()
{
$extension = new GuildCommandExtension(null, '::guild id::');
$extension = new GuildCommandExtension('::guild id::');
$extension->initialize($this->discord);

$hasRun = false;
Expand Down Expand Up @@ -98,7 +98,7 @@ public function testItDoesNotEmitEventsForDifferentGuilds()
*/
public function testItMapsNamesCorrectly(InteractionCreate $interaction, string $expectedName)
{
$extension = new GuildCommandExtension(null, '::guild id::');
$extension = new GuildCommandExtension('::guild id::');
$extension->initialize($this->discord);

$hasRun = false;
Expand Down
12 changes: 12 additions & 0 deletions tests/Rest/Helpers/Channel/MessageBuilderTest.php
Expand Up @@ -25,6 +25,18 @@ public function testSetNonce(): void
$this->assertEquals('::nonce::', $builder->getNonce());
}

public function testSetEnforceNonce(): void
{
$builder = new MessageBuilder();

$this->assertNull($builder->getEnforceNonce());

$builder->setEnforceNonce(true);

$this->assertTrue($builder->get()['enforce_nonce']);
$this->assertTrue($builder->getEnforceNonce());
}

public function testSetTts(): void
{
$builder = new MessageBuilder();
Expand Down

0 comments on commit 25855f8

Please sign in to comment.