From 4875e627f6f16553b1995d46620970b07946aac6 Mon Sep 17 00:00:00 2001 From: Exanlv <51094537+Exanlv@users.noreply.github.com> Date: Sun, 11 Jun 2023 16:57:57 +0200 Subject: [PATCH] feat: Add deletion bindings for application commands (#45) * Add deletion bindings for application commands * Fix deps --- composer.json | 4 ++-- src/Rest/GlobalCommand.php | 21 +++++++++++++++++++++ src/Rest/GuildCommand.php | 22 ++++++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 44072e97..659c60c5 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/src/Rest/GlobalCommand.php b/src/Rest/GlobalCommand.php index 0186d40e..dd6d7af8 100644 --- a/src/Rest/GlobalCommand.php +++ b/src/Rest/GlobalCommand.php @@ -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, @@ -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 + */ + public function deleteApplicationCommand( + string $applicationId, + string $commandId + ): ExtendedPromiseInterface { + return $this->http->delete( + Endpoint::bind( + Endpoint::GLOBAL_APPLICATION_COMMAND, + $applicationId, + $commandId, + ), + )->otherwise($this->logThrowable(...)); + } } diff --git a/src/Rest/GuildCommand.php b/src/Rest/GuildCommand.php index 122d23a9..af06568e 100644 --- a/src/Rest/GuildCommand.php +++ b/src/Rest/GuildCommand.php @@ -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, @@ -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 + */ + 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(...)); + } }