-
-
Notifications
You must be signed in to change notification settings - Fork 241
Guild
Guilds are part of discord. Guilds are known as 'Discord Servers' in the Discord application.
A Guild is Discord's equivalent of a server. It contains all the Members, Channels, Roles, Bans etc.
Return
- float the timestamp of when the guild was created.
Example
echo $guild->createdTimestamp();
function createRole([array<string|int, mixed> $data = [] ]) : ExtendedPromiseInterface
Creates a role in the guild with a given array of attributes. Returns the created role in a promise.
https://discord.com/developers/docs/resources/guild#create-guild-role
Example
$guild->createRole([
'name' => 'PHP',
'hoist' => true,
'mentionable' => false
])->done(function (Role $role) {
echo "Created role {$role->name}";
});
Returns an audit log object for the query.
https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log
Example
$guild->getAuditLog([
'user_id' => '123123123123123123'
'action_type' => Entry::MEMBER_KICK
])->done(function (AuditLog $auditLog) {
var_dump($auditLog);
});
Returns the channels invites.
https://discord.com/developers/docs/resources/guild#get-guild-invites
function getInvites() : ExtendedPromiseInterface
Retrieves a list of invites in the guild. Returns a collection of invites in a promise.
Example
$guild->getInvites()->done(function (Collection $invites) {
foreach ($invites as $invite) {
echo "Invite code {$invite->code} on {$invite->channel->name}";
}
});
function getVoiceRegions() : ExtendedPromiseInterface
Retrieves a list of valid voice regions. Returns a collection of objects describing voice regions in a promise.
Leaves the guild. Alias for $discord->guilds->leave($guild->id)
.
https://discord.com/developers/docs/resources/user#leave-guild
Example
$guild->leave();
function transferOwnership(Member|int $member) : ExtendedPromiseInterface
Transfers the ownership of the guild to another member. The bot must be the owner of the guild. Returns a promise with no data.
Unbans a member. Alias for $guild->bans->unban($user)
.
https://discord.com/developers/docs/resources/guild#remove-guild-ban
function unban(User|string $user) : ExtendedPromiseInterface
Example
$guild->unban('123123123123123123');
https://discord.com/developers/docs/resources/guild#modify-guild-role-positions
-
BanRepository
$guild->bans
-
ChannelRepository
$guild->channels
-
EmojiRepository
$guild->emojis
-
InviteRepository
$guild->invites
-
MemberRepository
$guild->members
-
RoleRepository
$guild->roles
Requires GUILD
intent
Your BOT must be member of the guild
Change 123123123123123123
below with the Guild ID you want to retrieve
Cached, synchronous:
$guild = $discord->guilds->get('id', '123123123123123123');
// Or using offsetGet
$guild = $discord->guilds['123123123123123123'];
Guild can be also retrieved from related objects:
-
Member
$guild = $member->guild;
returns the guild where the member is part of -
Channel
$guild = $channel->guild;
returns the guild where the channel belongs to -
Message
$guild = $message->guild;
returns the guild where the message is on -
Webhook
$guild = $webhook->guild;
returns the guild where the webhook belongs to -
Invite
$guild = $invite->guild;
returns the guild where the invite belongs to
If the code above returns null
(which most likely won't since guilds are always cached), you may need to fetch it first (Promise, asynchronous):
$discord->guilds->fetch('123123123123123123')->done(function (Guild $guild) {
// ...
});
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