Skip to content
This repository was archived by the owner on Feb 18, 2023. It is now read-only.

Commit 12838c2

Browse files
authored
Changes to Slash Command Response Types (#11)
* Update discord/interactions Changes to Slash Command Response Types and Flags March 5, 2021 Changes to interaction response types have been made to support better designs for Slash Commands: Type 2 Acknowledge has been deprecated Type 3 ChannelMessage has been deprecated Type 5 AcknowledgeWithSource has been renamed to DeferredChannelMessageWithSource These deprecated types will be removed and break on April 9, 2021. Additionally, flags has been documented on InteractionApplicationCommandCallbackData. Setting flags to 64 will make the interaction response ephemeral. * Deprecate Acknowledge * AcknowledgeWithSource -> DeferredChannelMessageWithSource Type 5 AcknowledgeWithSource has been renamed to DeferredChannelMessageWithSource * Deprecate ChannelMessage * Update composer.json * Keep original naming convention for functions * Backwards compatibility * Whoops
1 parent c149499 commit 12838c2

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"symfony/options-resolver": "^5.2",
1616
"monolog/monolog": "^2.2",
1717
"guzzlehttp/guzzle": "^7.2",
18-
"discord/interactions": "1.0.6",
18+
"discord/interactions": "1.0.7",
1919
"discord-php/http": "^8"
2020
},
2121
"autoload": {

src/Discord/Parts/Interaction.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,15 @@ public function setResolve(callable $resolve)
104104
* Acknowledges the interaction. At a bare minimum,
105105
* you should always acknowledge.
106106
*
107-
* @param bool $source Whether to show the source message in chat.
107+
* Source is unused
108+
* @see https://discord.com/developers/docs/change-log#changes-to-slash-command-response-types-and-flags
108109
*/
109-
public function acknowledge(bool $source = false)
110+
public function acknowledge(?bool $source = true)
110111
{
111112
($this->resolve)([
112-
'type' => $source ? InteractionResponseType::ACKNOWLEDGE_WITH_SOURCE : InteractionResponseType::ACKNOWLEDGE,
113+
'type' => InteractionResponseType::DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE,
113114
]);
115+
114116
}
115117

116118
/**
@@ -122,9 +124,11 @@ public function acknowledge(bool $source = false)
122124
* @param bool $tts Whether the message should be text-to-speech.
123125
* @param array[]|Embed[]|null $embeds An array of up to 10 embeds. Can also be an array of DiscordPHP embeds.
124126
* @param array|null $allowed_mentions Allowed mentions object. See Discord developer docs.
125-
* @param bool $source Whether the source message should be shown.
127+
*
128+
* Source is unused
129+
* @see https://discord.com/developers/docs/change-log#changes-to-slash-command-response-types-and-flags
126130
*/
127-
public function reply(string $content, bool $tts = false, ?array $embeds = null, ?array $allowed_mentions = null, bool $source = false)
131+
public function reply(string $content, bool $tts = false, ?array $embeds = null, ?array $allowed_mentions = null, ?bool $source = false)
128132
{
129133
$response = [
130134
'content' => $content,
@@ -134,7 +138,7 @@ public function reply(string $content, bool $tts = false, ?array $embeds = null,
134138
];
135139

136140
($this->resolve)([
137-
'type' => $source ? InteractionResponseType::CHANNEL_MESSAGE_WITH_SOURCE : InteractionResponseType::CHANNEL_MESSAGE,
141+
'type' => InteractionResponseType::CHANNEL_MESSAGE_WITH_SOURCE,
138142
'data' => $response,
139143
]);
140144
}

0 commit comments

Comments
 (0)