Skip to content

Guild Resource

Note

The following classes come from the discord.resources.guild module.


Guild dataclass

Bases: DataModel

Represents a Discord guild.

id: int instance-attribute

ID of the guild.

name: str = None class-attribute instance-attribute

Name of the guild.

icon: str = None class-attribute instance-attribute

Image hash of the guild's icon.

splash: str = None class-attribute instance-attribute

Image hash of the guild's splash.

owner: Optional[bool] = None class-attribute instance-attribute

If the member is the owner. (Get Current User Guilds)

owner_id: int = None class-attribute instance-attribute

OD of the owner of the guild.

roles: list[int] = None class-attribute instance-attribute

List of IDs registered in the guild.

emojis: list[EmojiModel] = None class-attribute instance-attribute

List of emojis registered in the guild.

mfa_level: int = None class-attribute instance-attribute

Required MFA level of the guild.

application_id: int = None class-attribute instance-attribute

ID of the application if the guild is created by a bot.

system_channel_id: int = None class-attribute instance-attribute

Channel ID where system messages go (e.g., welcome messages, boost events).

system_channel_flags: int = None class-attribute instance-attribute

System channel flags.

rules_channel_id: int = None class-attribute instance-attribute

Channel ID where rules are posted.

max_members: Optional[int] = None class-attribute instance-attribute

Maximum member capacity for the guild.

description: str = None class-attribute instance-attribute

Description of the guild.

banner: str = None class-attribute instance-attribute

Image hash of the guild's banner.

preferred_locale: str = None class-attribute instance-attribute

Preferred locale of the guild.

public_updates_channel_id: int = None class-attribute instance-attribute

Channel ID of announcement or public updates.

approximate_member_count: int = None class-attribute instance-attribute

Approximate number of members in the guild.

nsfw_level: int = None class-attribute instance-attribute

NSFW level of the guild.

safety_alerts_channel_id: int = None class-attribute instance-attribute

Channel ID for safety alerts.

fetch async

Fetch the Guild object by the given ID.

Parameters:

  • kwargs (Unpack[FetchGuildParams], default: {} ) –

    field-specific data

    Note

    If no kwargs are provided, default to with_counts = False

Returns:

  • Guild

    the Guild object

fetch_channels async

Fetch this guild's channels.

Returns:

  • list[Channel]

    list of the guild's channels

create_channel async

Create a channel in this guild.

Permissions
  • MANAGE_CHANNELS → required to create a channel

Parameters:

  • channel (GuildChannel) –

    the buildable guild channel

Returns:

fetch_guild_member async

Fetch a member in this guild.

Important

Requires the GUILD_MEMBERS privileged intent!

Parameters:

  • user_id (int) –

    user id of the member to fetch

Returns:

fetch_guild_members async

Fetch guild members in this guild.

Important

Requires the GUILD_MEMBERS privileged intent!

Parameters:

  • **kwargs (Unpack[FetchGuildMembersParams], default: {} ) –

    field-specific data

    Note

    If no kwargs are provided, default to 1 guild member limit.

Returns:

add_guild_member_role async

Append a role to a guild member of this guild.

Permissions
  • MANAGE_ROLES → required to add a role to the user

Parameters:

  • user_id (int) –

    id of the member for the role

  • role_id (int) –

    id of the role to append

remove_guild_member_role async

Remove a role from a guild member of this guild.

Permissions
  • MANAGE_ROLES → required to remove a role from the user

Parameters:

  • user_id (int) –

    id of the member with the role

  • role_id (int) –

    id of the role to remove

fetch_guild_role async

Fetch a role in this guild.

Parameters:

  • role_id (int) –

    id of the role to fetch

Returns:

fetch_guild_roles async

Fetch all roles in this guild.

Returns:

  • list[RoleModel]

    list of fetched roles' data

create_guild_role async

Create a role in this guild.

Permissions
  • MANAGE_ROLES → required to add a role to the guild

Parameters:

  • role (Role) –

    role to create

Returns:

modify_guild_role async

Modify a role in this guild.

Permissions
  • MANAGE_ROLES → required to modify a role in the guild

Parameters:

  • role (Role) –

    role with changes

Returns:

delete_guild_role async

Delete a role in this guild.

Permissions
  • MANAGE_ROLES → required to delete a role in the guild

Parameters:

  • role_id (int) –

    id of role to delete


FetchGuildParams

Bases: TypedDict

Params when fetching a guild.

with_counts: Optional[bool] instance-attribute

If True, return the approximate member and presence counts for the guild.


FetchGuildMembersParams

Bases: TypedDict

Params when fetching guild members.

limit: int instance-attribute

Max number of members to return Range 1 - 1000. Default 1.

after: int instance-attribute

Highest user id in previous page.