Skip to content
SQKo edited this page Dec 9, 2023 · 5 revisions

Users are part of Bot client. See Member for Guild Member object.

use Discord\Parts\User\User;

A user is a general discord user that is not attached to a guild.


Get a Specific User

Your BOT must share Guild with the User

Change 123123123123123123 below with the User ID you want to retrieve

Cached, synchronous (i.e. loadAllMembers option is true):

$user = $discord->users->get('id', '123123123123123123');

Cached User can be also retrieved from related objects:

  • Application $user = $application->user; the application owner
  • Ban $user = $ban->user; the banned user
  • Audit Log Entry $user = $entry->user; user who made the changes
  • Guild $user = $guild->owner; the guild owner
  • Invite $user = $invite->inviter; user who created the invite
  • Member $user = $member->user; user of the member
  • Message $user = $message->author; author of the message
  • Webhook $user = $webhook->user; user who created the webhook

If the code above returns null, you may need to fetch it first (Promise, synchronous):

$discord->users->fetch('123123123123123123')->then(function (User $user) {
    // ...
})->done();

https://discord.com/developers/docs/resources/user#get-user

Clone this wiki locally