Skip to content
SQKo edited this page May 30, 2022 · 30 revisions

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

Returns an audit log object for the query.

https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log

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.

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

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

https://discord.com/developers/docs/resources/guild#modify-guild-role-positions

Requires GUILD intent

GUILD_CREATE

GUILD_DELETE

GUILD_UPDATE


Get a Specific Guild

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'];

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) {
    // ...
});

Guild can be also retrieved from related objects:

  • Channel $guild = $channel->guild; returns the guild where the channel belongs to
  • Message $guild = $message->guild; returns the guild where the message is on
Clone this wiki locally