-
Notifications
You must be signed in to change notification settings - Fork 237
Member
Members can be either part of Guild or Voice Channel. See User for Discord User object.
use Discord\Parts\User\Member;
This requires SERVER MEMBERS INTENT && configure in Discord call.
$discord = new Discord([
'token' => 'YOURTOKEN',
'intents' => Intents::getDefaultIntents() | Intents::GUILD_MEMBERS,
]);
https://discord.com/developers/applications/yourapp/bot
A member is a relationship between a user and a guild. It contains user-to-guild specific data like roles.
function addRole(Role|string $role) : ExtendedPromiseInterface
function ban([int|null $daysToDeleteMessages = null ][, string|null $reason = null ]) : ExtendedPromiseInterface
function getPermissions([Channel|null $channel = null ]) : RolePermission
function moveMember(Channel|string $channel) : ExtendedPromiseInterface
function removeRole(Role|string $role) : ExtendedPromiseInterface
function setNickname([string|null $nick = null ]) : ExtendedPromiseInterface
function sendMessage(MessageBuilder $message) : ExtendedPromiseInterface
Requires GUILD_MEMBERS
intent
Retrieving a Guild Member requires GUILD_MEMBERS
intent
You must first get the Guild object to use the code below. Change 123123123123123123
below with the User ID you want to retrieve
Cached, synchrounous (i.e. loadAllMembers
option is true
):
$member = $guild->members->get('id', '123123123123123123');
Cached Member can be also retrieved from related objects:
-
Message
$member = $message->member;
member who sent the message (only in a guild)
If the code above returns null
, you may need to fetch it first (Promise, asynchrounous):
$guild->members->fetch('123123123123123123')->then(function (Member $member) {
// ...
})->done();
https://discord.com/developers/docs/resources/guild#get-guild-member
Your BOT must have manage_nicknames
permission
Set $member
nick name to "newnick":
$member->setNickname('newnick')->then(function () {
// ...
})->done();
https://discord.com/developers/docs/resources/guild#modify-guild-member
Note: This wiki is currently Work In Progress. Consider reading the docs instead.
- Application Command (Slash based)
Command Client (Message based)
- Activity
- Application
- Guild
- Private Channel
- User
Components
-
ActionRow
- Buttons
- Option (commands)
- SelectMenu
- TextInput
Builders