Skip to content

Guild Resource

Note

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


Guild dataclass

Bases: BaseResource

Represents a Discord guild.

id: int instance-attribute

ID of the guild.

context: Any instance-attribute

Associated user data.

fetch async

Fetch the Guild object by the given ID.

Parameters:

  • with_counts (bool, default: False ) –

    return the approximate member and presence counts for the guild. Defaults to False.

Returns:

edit async

Edit this guild. Fires GuildUpdateEvent.

Parameters:

Returns:

fetch_channels async

Fetch this guild's channels.

Note

Does not include threads!

Returns:

  • list[ChannelModel]

    queried list of the guild's channels

fetch_active_threads async

Fetch all active threads in a guild (private and public).

Note

Threads are ordered by their ID in descending order.

Returns:

create_channel async

Create a channel in this guild. Fires ChannelCreateEvent.

Permissions

Requires MANAGE_CHANNELS

Parameters:

Returns:

fetch_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_members async

Fetch guild members in this guild.

Important

Requires the GUILD_MEMBERS privileged intent!

Parameters:

  • limit (int, default: 1 ) –

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

  • after (int, default: None ) –

    highest user ID in previous page

Returns:

add_member_role async

Append a role to a guild member of this guild. Fires GuildMemberUpdateEvent.

Permissions

Requires MANAGE_ROLES

Parameters:

  • user_id (int) –

    ID of the member for the role

  • role_id (int) –

    ID of the role to append

remove_member_role async

Remove a role from a guild member of this guild. Fires GuildMemberUpdateEvent.

Permissions

Requires MANAGE_ROLES

Parameters:

  • user_id (int) –

    ID of the member with the role

  • role_id (int) –

    ID of the role to remove

search_members async

Fetch guild members whose username or nickname starts with the provided query.

Parameters:

  • query (str, default: None ) –

    query string to match against

  • limit (int, default: 1 ) –

    Max number of members to return. Max 1000. Defaults to 1.

Returns:

  • list[GuildMemberModel]

    list[GuildMemberModel]: queried list of guild members

edit_member async

Edit a guild member's attributes. Fires GuildMemberUpdateEvent.

Parameters:

  • user_id (int) –

    ID of the member to edit

Returns:

remove_member async

Remove a member from this guild. Fires GuildMemberRemoveEvent.

Permissions

Requires KICK_MEMBERS

Parameters:

  • user_id (int) –

    ID of the user to kick

fetch_ban async

Fetch a guild ban for the given user ID.

Permissions

Requires BAN_MEMBERS

Parameters:

  • user_id (int) –

    ID of the user to fetch

Returns:

  • GuildBan

    queried ban

fetch_bans async

Fetch bans in this guild.

Permissions

Requires BAN_MEMBERS

Parameters:

  • limit (int, default: 1000 ) –

    max number of users to return. Defaults to 1000.

  • before (int, default: None ) –

    fetch users before this ID

  • after (int, default: None ) –

    fetch users after this ID

Returns:

  • list[GuildBan]

    queried list of guild bans

create_ban async

Create a guild ban and optionally delete messages sent by the banned user. Fires GuildBanAddEvent.

Permissions

Requires BAN_MEMBERS

Parameters:

  • user_id (int) –

    ID of the user to ban

  • delete_message_seconds (int, default: 0 ) –

    seconds back to delete messages. Max 604800 (7 days). Defaults to 0.

remove_ban async

Remove the ban for a user. Fires GuildBanRemoveEvent.

Permissions

Requires BAN_MEMBERS

Parameters:

  • user_id (int) –

    ID of the user in which to remove the ban

bulk_create_ban async

Create guild bans and optionally delete messages sent by the banned users.

Permissions

Requires BAN_MEMBERS and MANAGE_GUILD

Parameters:

Returns:

fetch_role_member_counts async

Fetch a map of role IDs to number of members with the role.

Note

Does not include @everyone role.

Returns:

  • dict

    map of role IDs to member count

fetch_role async

Fetch a role in this guild.

Parameters:

  • role_id (int) –

    ID of the role to fetch

Returns:

fetch_roles async

Fetch all roles in this guild.

Returns:

  • list[RoleModel]

    queried list of guild roles

create_role async

Create a role in this guild. Fires RoleCreateEvent.

Permissions

Requires MANAGE_ROLES

Parameters:

Returns:

edit_role async

Edit a role in this guild. Fires RoleUpdateEvent.

Permissions

Requires MANAGE_ROLES

Parameters:

  • role_id (int) –

    ID of role to edit

  • options (EditGuildRoleParams, default: {} ) –

    role with fields to edit

Returns:

delete_role async

Delete a role in this guild. Fires RoleDeleteEvent.

Permissions

Requires MANAGE_ROLES

Parameters:

  • role_id (int) –

    ID of role to delete

fetch_invites async

Fetch this guild's invites with no metadata.

Permissions

Requires MANAGE_GUILD or VIEW_AUDIT_LOG

Returns:

  • list[InviteModel]

    queried list of invites without metadata

fetch_invites_with_metadata async

Fetch this guild's invites with metadata.

Permissions

Requires MANAGE_GUILD and MANAGE_GUILD or VIEW_AUDIT_LOG

Returns:

  • list[InviteModel]

    queried list of invites with metadata

fetch_integrations async

Fetch this guild's integrations.

Permissions

Requires MANAGE_GUILD

Returns:

delete_integration async

Delete the attached integration object for this guild. Fires GuildIntegrationUpdateEvent and GuildIntegrationDeleteEvent.

Permissions

Requires MANAGE_GUILD

Parameters:

  • integration_id (int) –

    ID of the integration to delete

fetch_welcome_screen async

Fetch the welcome screen for this guild.

Permissions

Requires MANAGE_GUILD if welcome screen is not enabled

Returns:

edit_welcome_screen async

Edit this guild's welcome screen. May fire GuildUpdateEvent.

Permissions

Requires MANAGE_GUILD

Parameters:

  • options (EditGuildWelcomeScreen, default: {} ) –

    fields to edit

Returns:

fetch_onboarding async

Fetch this guild's onboarding flow.

Returns:

edit_onboarding async

Modifies this guild's onboarding flow.

Permissions

Requires MANAGE_GUILD and MANAGE_ROLES

Note

Must be at least 7 Default Channels and at least 5 allow sending message to the @everyone role. Constraints depend on the new mode.

Parameters:

Returns:

fetch_sticker async

Fetch a sticker from this guild.

Note

Includes the user field if the bot has CREATE_GUILD_EXPRESSIONS and MANAGE_GUILD_EXPRESSIONS

Parameters:

  • sticker_id (int) –

    ID of the sticker to fetch

Returns:

fetch_stickers async

Fetch this guild's stickers.

Note

Includes the user field if the bot has CREATE_GUILD_EXPRESSIONS and MANAGE_GUILD_EXPRESSIONS

Returns:

  • list[StickerModel]

    list[StickerModel]: queried guild stickers

create_sticker async

Add a sticker to this guild. Fires GuildStickersUpdateEvent.

Permissions

Requires CREATE_GUILD_EXPRESSIONS

Parameters:

  • sticker (GuildStickerPart) –

    sticker to create

  • file (ImageAssetPart) –

    the sticker file to upload

    Note

    Accepted file types: PNG, APNG, GIF, Lottie JSON file.

Returns:

edit_sticker async

Edit a sticker from this guild. Fires GuildStickersUpdateEvent.

Permissions

Requires CREATE_GUILD_EXPRESSIONS or MANAGE_GUILD_EXPRESSIONS. Requires MANAGE_GUILD_EXPRESSIONS if not created by the bot.

Parameters:

  • sticker_id (int) –

    ID of the sticker to delete

  • options (EditGuildStickerParams, default: {} ) –

    fields to edit

delete_sticker async

Delete a sticker from this guild. Fires GuildStickersUpdateEvent.

Permissions

Requires CREATE_GUILD_EXPRESSIONS or MANAGE_GUILD_EXPRESSIONS. Requires MANAGE_GUILD_EXPRESSIONS if not created by the bot.

Parameters:

  • sticker_id (int) –

    ID of the sticker to delete