discord-php / DiscordPHP

An API to interact with the popular messaging app Discord
MIT License
977 stars 236 forks source link

How can I get this event? #1125

Closed novikov9999 closed 1 year ago

novikov9999 commented 1 year ago

Hi all. I'm testing an application and I need to receive a message from a bot in a separate channel. Regular messages are successfully received by the MESSAGE_CREATE event. How can I get such an event?

Screenshot 2023-06-03 at 18 46 06

My code does not react to the appearance of such an event.

include __DIR__.'/vendor/autoload.php';

use Discord\Discord;
use Discord\Parts\Channel\Message;
use Discord\WebSockets\Intents;
use Discord\WebSockets\Event;
use Discord\Parts\Interactions\Interaction;

$discord = new Discord([
    'token' => 'TOKEN',
    'intents' => Intents::getDefaultIntents() | Intents::GUILD_MEMBERS | Intents::GUILD_PRESENCES | Intents::GUILDS | Intents::GUILD_BANS, 
    'loadAllMembers' => true
]);

$discord->on('ready', function (Discord $discord) {

    $discord->on(Event::INTERACTION_CREATE, function (Message $interaction, Discord $discord) {
        echo 'INTERACTION_CREATE'.PHP_EOL;
    });

});

$discord->run();
key2peace commented 1 year ago

it's an ephermal message (hence the text below it saying 'Only you can see this') which pretty much explains why your bot won't see it then