Get Guild(s)

A help page explaining how to get one / more guilds from client's cache

When working with the bot, you obviously have to get a Guild instance because sometimes, it's not included in the event.

This help page is going to show you how to get a guild by snowflake (id), a random guild or all guilds registered in cache.

Discord sends guilds async so the client is going to be ready before the guilds are initalized. Don't use those method in or before ClientReadyEvent

Get a Guild by Snowflake

This can simply be done by

$client->getGuild("snowflake");

It will return a Guild instance or null on failure, if you don't know how to get the Client instance visit This page.

Get a random Guild

This is pretty simple too, and yes it's the correct function, just don't pass any parameters

$client->getGuild();

It will only return null when there's no guild registered, if you don't know how to get the Client instance visit This page.

Get all Guilds

This action can simply be performed by typing

$client->getGuilds();

If you don't know how to get the Client instance visit This page.

Last updated