discord-php / DiscordPHP

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

Check where the message came from and get the attachment #1080

Closed CatAnonymous closed 1 year ago

CatAnonymous commented 1 year ago

I have 2 questions:

  1. Is it possible to check the user is sending messages from "channel" or "private message"?
  2. Is it possible to get attachments (images, text, audio...) from users?

    Please give me the solution, thankyou!

    $discord->on('ready', function (Discord $discord) {
    echo "Bot is online!", PHP_EOL;
    
    $discord->on(Event::MESSAGE_CREATE, function (Message $message, Discord $discord) {
        echo "{$message->author->username}: {$message->content}", PHP_EOL;
        $message->reply('...');
    }