Skip to content

Commit

Permalink
feat: Add deletion bindings for application commands (#45)
Browse files Browse the repository at this point in the history
* Add deletion bindings for application commands

* Fix deps
  • Loading branch information
Exanlv authored Jun 11, 2023
1 parent 8b1ddb1 commit 4875e62
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"mockery/mockery": "dev-master",
"seregazhuk/react-promise-testing": "^0.6.1",
"squizlabs/php_codesniffer": "^3.7",
"cboden/ratchet": "^0.4.4",
"phpmd/phpmd": "^2.13",
"symfony/var-dumper": "^6.2"
"symfony/var-dumper": "^6.2",
"mockery/mockery": "^1.6"
},
"scripts": {
"md": "phpmd src text ruleset.xml",
Expand Down
21 changes: 21 additions & 0 deletions src/Rest/GlobalCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class GlobalCommand extends HttpResource
{
/**
* @see https://discord.com/developers/docs/interactions/application-commands#making-a-global-command
*
* @return ExtendedPromiseInterface<\Ragnarok\Fenrir\Parts\ApplicationCommand>
*/
public function createApplicationCommand(
string $applicationId,
Expand All @@ -35,4 +37,23 @@ public function createApplicationCommand(
ApplicationCommand::class
)->otherwise($this->logThrowable(...));
}


/**
* @see https://discord.com/developers/docs/interactions/application-commands#delete-global-application-command
*
* @return ExtendedPromiseInterface<void>
*/
public function deleteApplicationCommand(
string $applicationId,
string $commandId
): ExtendedPromiseInterface {
return $this->http->delete(
Endpoint::bind(
Endpoint::GLOBAL_APPLICATION_COMMAND,
$applicationId,
$commandId,
),
)->otherwise($this->logThrowable(...));
}
}
22 changes: 22 additions & 0 deletions src/Rest/GuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class GuildCommand extends HttpResource
{
/**
* @see https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command
*
* @return ExtendedPromiseInterface<\Ragnarok\Fenrir\Parts\ApplicationCommand>
*/
public function createApplicationCommand(
string $applicationId,
Expand All @@ -37,4 +39,24 @@ public function createApplicationCommand(
ApplicationCommand::class
)->otherwise($this->logThrowable(...));
}

/**
* @see https://discord.com/developers/docs/interactions/application-commands#delete-guild-application-command
*
* @return ExtendedPromiseInterface<void>
*/
public function deleteApplicationCommand(
string $applicationId,
string $guildId,
string $commandId
): ExtendedPromiseInterface {
return $this->http->delete(
Endpoint::bind(
Endpoint::GUILD_APPLICATION_COMMAND,
$applicationId,
$guildId,
$commandId,
),
)->otherwise($this->logThrowable(...));
}
}

0 comments on commit 4875e62

Please sign in to comment.