Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promise Interaction without any value #1200

Closed
DT-666 opened this issue Feb 21, 2024 · 1 comment
Closed

Promise Interaction without any value #1200

DT-666 opened this issue Feb 21, 2024 · 1 comment

Comments

@DT-666
Copy link

DT-666 commented Feb 21, 2024

Environment
[2024-02-21T08:37:56.323915+00:00] DiscordPHP.DEBUG: Initializing DiscordPHP v7.3.5 (DiscordPHP-Http: v9.1.9 & Gateway: v9) on PHP 8.0.30

  • PHP Version:
    • php-8.0.30-Win32-vs16-x86
  • DiscordPHP Version:
    • DiscordPHP-7.3.5

Describe the bug
On a slash command, when i reply or aknowledge, with a premise ->then or ->done, the parameter of the function is always null, not as the sendMessage one which as got the new message object

To Reproduce
Steps to reproduce the behavior:
$bot->getDiscord()->listenCommand('dt', function (Interaction $interaction) {
global $bot;
$discord = $bot->getDiscord();
$msg = 'Bonjour DT !'.PHP_EOL;
$is_admin = false;
if($interaction->user->id == '127425489399840768') {
$is_admin = true;
$interaction->acknowledge()->then(
function (Interaction $interaction) {
echo 'ackT', PHP_EOL;
var_dump($interaction);
$interaction->sendFollowUpMessage(MessageBuilder::new()->setContent('go'), true);
},
function ($error) {
echo 'ackT', PHP_EOL;
var_dump($error);
}
)
->done(
function (Interaction $interaction) {
echo 'ackD', PHP_EOL;
var_dump($interaction);
$interaction->sendFollowUpMessage(MessageBuilder::new()->setContent('go'), true);
},
function ($error) {
echo 'ackD', PHP_EOL;
var_dump($error);
}
);
};
});

Expected behavior
having the parameter of $interaction->sendFollowUpMessage with the value of listenCommand('dt', function (Interaction $interaction) {

It's the same with the functino replyMessage

Additional context
Logs :
[2024-02-21T08:38:00.492972+00:00] DiscordPHP.DEBUG: http not checking {"waiting":0,"empty":true} []
ackD
object(TypeError)#4776 (7) {
["message":protected]=>
string(218) "{closure}(): Argument #1 ($interaction) must be of type Discord\Parts\Interactions\Interaction, null given, called in C:\PHP\www\include\discord\DiscordPHP-7.3.4\vendor\react\promise\src\FulfilledPromise.php on line 28"
["string":"Error":private]=>
string(0) ""
["code":protected]=>
int(0)
["file":protected]=>
string(47) "C:\PHP\www\bots\discord\swgoh\commands\test.php"
["line":protected]=>
int(25)
["trace":"Error":private]=>
array(40) {
[0]=>

@DT-666 DT-666 added the bug label Feb 21, 2024
@SQKo SQKo removed the bug label Feb 24, 2024
@SQKo
Copy link
Member

SQKo commented Feb 24, 2024

This works as expected, responding to interaction returns no content as specified in the endpoint https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response
Unlike normal send message which does return a message data https://discord.com/developers/docs/resources/channel#create-message
Same for listenCommand() there is $interaction argument because the interaction data is received from the event https://discord.com/developers/docs/topics/gateway-events#interaction-create

If you wish to get your last interaction object, pass it inside function () use ($interaction)

@SQKo SQKo closed this as not planned Won't fix, can't repro, duplicate, stale Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants