Guilds¶
This section documents everything related to Guilds - main hubs for communication in Discord, referred to as Servers in the official UI.
Discord Models¶
Guild¶
- afk_channel
- afk_timeout
- approximate_member_count
- approximate_presence_count
- banner
- bitrate_limit
- categories
- channels
- chunked
- created_at
- default_notifications
- default_role
- description
- discovery_splash
- emoji_limit
- emojis
- explicit_content_filter
- features
- filesize_limit
- forum_channels
- icon
- id
- large
- max_members
- max_presences
- max_stage_video_channel_users
- max_video_channel_users
- me
- media_channels
- member_count
- members
- mfa_level
- name
- nsfw_level
- owner
- owner_id
- preferred_locale
- premium_progress_bar_enabled
- premium_subscriber_role
- premium_subscribers
- premium_subscription_count
- premium_tier
- public_updates_channel
- region
- roles
- rules_channel
- safety_alerts_channel
- scheduled_events
- self_role
- shard_id
- splash
- stage_channels
- stage_instances
- sticker_limit
- stickers
- system_channel
- system_channel_flags
- text_channels
- threads
- unavailable
- vanity_url_code
- verification_level
- voice_channels
- voice_client
- widget_channel_id
- widget_enabled
- asyncactive_threads
- defaudit_logs
- asyncban
- defbans
- asyncbulk_ban
- asyncbulk_fetch_command_permissions
- defby_category
- asyncchange_voice_state
- asyncchunk
- asynccreate_automod_rule
- asynccreate_category
- asynccreate_category_channel
- asynccreate_custom_emoji
- asynccreate_forum_channel
- asynccreate_integration
- asynccreate_media_channel
- asynccreate_role
- asynccreate_scheduled_event
- asynccreate_stage_channel
- asynccreate_sticker
- asynccreate_template
- asynccreate_text_channel
- asynccreate_voice_channel
- asyncdelete
- asyncdelete_emoji
- asyncdelete_sticker
- asyncedit
- asyncedit_mfa_level
- asyncedit_role_positions
- asyncedit_welcome_screen
- asyncedit_widget
- asyncestimate_pruned_members
- asyncfetch_automod_rule
- asyncfetch_automod_rules
- asyncfetch_ban
- asyncfetch_channel
- asyncfetch_channels
- asyncfetch_command_permissions
- asyncfetch_emoji
- asyncfetch_emojis
- asyncfetch_member
- deffetch_members
- asyncfetch_role
- asyncfetch_roles
- asyncfetch_scheduled_event
- asyncfetch_scheduled_events
- asyncfetch_sticker
- asyncfetch_stickers
- asyncfetch_voice_regions
- asyncfetch_voice_state
- defget_channel
- defget_channel_or_thread
- defget_command
- defget_command_named
- defget_member
- defget_member_named
- asyncget_or_fetch_member
- asyncget_or_fetch_members
- defget_role
- defget_scheduled_event
- defget_stage_instance
- defget_thread
- asyncgetch_member
- asyncgetch_members
- asyncintegrations
- asyncinvites
- asynckick
- asyncleave
- asynconboarding
- asyncprune_members
- asyncquery_members
- asyncsearch_members
- asynctemplates
- asynctimeout
- asyncunban
- asyncvanity_invite
- asyncwebhooks
- asyncwelcome_screen
- asyncwidget
- defwidget_image_url
- asyncwidget_settings
- class disnake.Guild[source]¶
Represents a Discord guild.
This is referred to as a “server” in the official Discord UI.
- x == y
Checks if two guilds are equal.
- x != y
Checks if two guilds are not equal.
- hash(x)
Returns the guild’s hash.
- str(x)
Returns the guild’s name.
- stickers¶
All stickers that the guild owns.
New in version 2.0.
- Type:
Tuple[
GuildSticker
, …]
- afk_channel¶
The channel that denotes the AFK channel.
None
if it doesn’t exist.- Type:
Optional[
VoiceChannel
]
- owner_id¶
The guild owner’s ID. Use
Guild.owner
if you need aMember
object instead.- Type:
Whether the guild is unavailable. If this is
True
then the reliability of other attributes outside ofGuild.id
is slim and they might all beNone
. It is best to not do anything with the guild if it is unavailable.Check
on_guild_unavailable()
andon_guild_available()
events.- Type:
- max_members¶
The maximum amount of members for the guild.
Note
This attribute is only available via
Client.fetch_guild()
.- Type:
Optional[
int
]
- max_video_channel_users¶
The maximum amount of users in a video channel.
New in version 1.4.
- Type:
Optional[
int
]
- max_stage_video_channel_users¶
The maximum amount of users in a stage video channel.
- Type:
Optional[
int
]
- mfa_level¶
Indicates the guild’s two-factor authentication level. If this value is 0 then the guild does not require 2FA for their administrative members to take moderation actions. If the value is 1, then 2FA is required.
- Type:
- verification_level¶
The guild’s verification level.
- Type:
- explicit_content_filter¶
The guild’s explicit content filter.
- Type:
- default_notifications¶
The guild’s notification settings.
- Type:
- features¶
A list of features that the guild has. The features that a guild can have are subject to arbitrary change by Discord.
A partial list of features is below:
ANIMATED_BANNER
: Guild can upload an animated banner.ANIMATED_ICON
: Guild can upload an animated icon.AUTO_MODERATION
: Guild has set up auto moderation rules.BANNER
: Guild can upload and use a banner. (i.e.banner
)COMMUNITY
: Guild is a community server.CREATOR_MONETIZABLE_PROVISIONAL
: Guild has enabled monetization.CREATOR_STORE_PAGE
: Guild has enabled the role subscription promo page.DEVELOPER_SUPPORT_SERVER
: Guild is set as a support server in the app directory.DISCOVERABLE
: Guild shows up in Server Discovery.ENABLED_DISCOVERABLE_BEFORE
: Guild had Server Discovery enabled at least once.FEATURABLE
: Guild is able to be featured in Server Discovery.HAS_DIRECTORY_ENTRY
: Guild is listed in a student hub.HUB
: Guild is a student hub.INVITE_SPLASH
: Guild’s invite page can have a special splash.INVITES_DISABLED
: Guild has paused invites, preventing new users from joining.LINKED_TO_HUB
: Guild is linked to a student hub.MEMBER_VERIFICATION_GATE_ENABLED
: Guild has Membership Screening enabled.MORE_EMOJI
: Guild has increased custom emoji slots.MORE_STICKERS
: Guild has increased custom sticker slots.NEWS
: Guild can create news channels.NEW_THREAD_PERMISSIONS
: Guild is using the new thread permission system.PARTNERED
: Guild is a partnered server.PREVIEW_ENABLED
: Guild can be viewed before being accepted via Membership Screening.PRIVATE_THREADS
: Guild has access to create private threads (no longer has any effect).RAID_ALERTS_DISABLED
: Guild has disabled alerts for join raids in the configured safety alerts channel.ROLE_ICONS
: Guild has access to role icons.ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE
: Guild has role subscriptions that can be purchased.ROLE_SUBSCRIPTIONS_ENABLED
: Guild has enabled role subscriptions.SEVEN_DAY_THREAD_ARCHIVE
: Guild has access to the seven day archive time for threads (no longer has any effect).TEXT_IN_VOICE_ENABLED
: Guild has text in voice channels enabled (no longer has any effect).THREE_DAY_THREAD_ARCHIVE
: Guild has access to the three day archive time for threads (no longer has any effect).THREADS_ENABLED
: Guild has access to threads (no longer has any effect).TICKETED_EVENTS_ENABLED
: Guild has enabled ticketed events (no longer has any effect).VANITY_URL
: Guild can have a vanity invite URL (e.g. discord.gg/disnake).VERIFIED
: Guild is a verified server.VIP_REGIONS
: Guild has VIP voice regions.WELCOME_SCREEN_ENABLED
: Guild has enabled the welcome screen.
- Type:
List[
str
]
Whether the server boost progress bar is enabled.
- Type:
The premium tier for this guild. Corresponds to “Nitro Server” in the official UI. The number goes from 0 to 3 inclusive.
- Type:
The number of “boosts” this guild currently has.
- Type:
- preferred_locale¶
The preferred locale for the guild. Used when filtering Server Discovery results to a specific language.
- Type:
- approximate_member_count¶
The approximate number of members in the guild. Only available for manually fetched guilds.
New in version 2.3.
- Type:
Optional[
int
]
- approximate_presence_count¶
The approximate number of members currently active in the guild. This includes idle, dnd, online, and invisible members. Offline members are excluded. Only available for manually fetched guilds.
New in version 2.3.
- Type:
Optional[
int
]
- widget_enabled¶
Whether the widget is enabled.
New in version 2.5.
Note
This value is unreliable and will only be set after the guild was updated at least once. Avoid using this and use
widget_settings()
instead.- Type:
Optional[
bool
]
- widget_channel_id¶
The widget channel ID, if set.
New in version 2.5.
Note
This value is unreliable and will only be set after the guild was updated at least once. Avoid using this and use
widget_settings()
instead.- Type:
Optional[
int
]
- vanity_url_code¶
The vanity invite code for this guild, if set.
To get a full
Invite
object, seeGuild.vanity_invite
.New in version 2.5.
- Type:
Optional[
str
]
- async for ... in fetch_members(*, limit=1000, after=None)[source]¶
Retrieves an
AsyncIterator
that enables receiving the guild’s members.In order to use this, the
members
intent must be enabled in the developer portal.Note
This method is an API call. For general usage, consider
members
instead.New in version 1.3.
Changed in version 2.9: No longer requires the intent to be enabled on the websocket connection.
All parameters are optional.
- Parameters:
limit (Optional[
int
]) – The number of members to retrieve. Defaults to 1000. PassNone
to fetch all members. Note that this is potentially slow.after (Optional[Union[
abc.Snowflake
,datetime.datetime
]]) – Retrieve members after this date or object. If a datetime is provided, it is recommended to use a UTC aware datetime. If the datetime is naive, it is assumed to be local time.
- Raises:
ClientException – The members intent is not enabled in the developer portal.
HTTPException – Retrieving the members failed.
- Yields:
Member
– The member with the member data parsed.
Examples
Usage
async for member in guild.fetch_members(limit=150): print(member.name)
Flattening into a list
members = await guild.fetch_members(limit=150).flatten() # members is now a list of Member...
- async for ... in audit_logs(*, limit=100, before=None, after=None, user=None, action=None, oldest_first=False)[source]¶
Returns an
AsyncIterator
that enables receiving the guild’s audit logs.You must have
view_audit_log
permission to use this.Entries are returned in order from newest to oldest by default; pass
oldest_first=True
to reverse the iteration order.Examples
Getting the first 100 entries:
async for entry in guild.audit_logs(limit=100): print(f'{entry.user} did {entry.action} to {entry.target}')
Getting entries for a specific action:
async for entry in guild.audit_logs(action=disnake.AuditLogAction.ban): print(f'{entry.user} banned {entry.target}')
Getting entries made by a specific user:
entries = await guild.audit_logs(limit=None, user=guild.me).flatten() await channel.send(f'I made {len(entries)} moderation actions.')
- Parameters:
limit (Optional[
int
]) – The number of entries to retrieve. IfNone
retrieve all entries.before (Optional[Union[
abc.Snowflake
,datetime.datetime
]]) – Retrieve entries before this date or entry. If a datetime is provided, it is recommended to use a UTC aware datetime. If the datetime is naive, it is assumed to be local time.after (Optional[Union[
abc.Snowflake
,datetime.datetime
]]) – Retrieve entries after this date or entry. If a datetime is provided, it is recommended to use a UTC aware datetime. If the datetime is naive, it is assumed to be local time.user (Optional[
abc.Snowflake
]) – The moderator to filter entries from.action (Optional[
AuditLogAction
]) – The action to filter with.oldest_first (
bool
) –If set to
True
, return entries in oldest->newest order. Defaults toFalse
.New in version 2.9.
- Raises:
Forbidden – You are not allowed to fetch audit logs
HTTPException – An error occurred while fetching the audit logs.
- Yields:
AuditLogEntry
– The audit log entry.
- get_command(application_command_id, /)[source]¶
Gets a cached application command matching the specified ID.
- Parameters:
application_command_id (
int
) – The application command ID to search for.- Returns:
The application command if found, or
None
otherwise.- Return type:
Optional[Union[
APIUserCommand
,APIMessageCommand
,APISlashCommand
]]
- get_command_named(name, /)[source]¶
Gets a cached application command matching the specified name.
- Parameters:
name (
str
) – The application command name to search for.- Returns:
The application command if found, or
None
otherwise.- Return type:
Optional[Union[
APIUserCommand
,APIMessageCommand
,APISlashCommand
]]
- property channels[source]¶
A list of channels that belong to this guild.
- Type:
List[
abc.GuildChannel
]
- property threads[source]¶
A list of threads that you have permission to view.
New in version 2.0.
- Type:
List[
Thread
]
- property large[source]¶
Whether the guild is a ‘large’ guild.
A large guild is defined as having more than
large_threshold
count members, which for this library is set to the maximum of 250.- Type:
- property voice_channels[source]¶
A list of voice channels that belong to this guild.
This is sorted by the position and are in UI order from top to bottom.
- Type:
List[
VoiceChannel
]
- property stage_channels[source]¶
A list of stage channels that belong to this guild.
New in version 1.7.
This is sorted by the position and are in UI order from top to bottom.
- Type:
List[
StageChannel
]
- property forum_channels[source]¶
A list of forum channels that belong to this guild.
This is sorted by the position and are in UI order from top to bottom.
New in version 2.5.
- Type:
List[
ForumChannel
]
- property media_channels[source]¶
A list of media channels that belong to this guild.
This is sorted by the position and are in UI order from top to bottom.
New in version 2.10.
- Type:
List[
MediaChannel
]
- property me[source]¶
Similar to
Client.user
except an instance ofMember
. This is essentially used to get the member version of yourself.- Type:
- property voice_client[source]¶
Returns the
VoiceProtocol
associated with this guild, if any.- Type:
Optional[
VoiceProtocol
]
- property text_channels[source]¶
A list of text channels that belong to this guild.
This is sorted by the position and are in UI order from top to bottom.
- Type:
List[
TextChannel
]
- property categories[source]¶
A list of categories that belong to this guild.
This is sorted by the position and are in UI order from top to bottom.
- Type:
List[
CategoryChannel
]
- by_category()[source]¶
Returns every
CategoryChannel
and their associated channels.These channels and categories are sorted in the official Discord UI order.
If the channels do not have a category, then the first element of the tuple is
None
.- Returns:
The categories and their associated channels.
- Return type:
List[Tuple[Optional[
CategoryChannel
], List[abc.GuildChannel
]]]
- get_channel_or_thread(channel_id, /)[source]¶
Returns a channel or thread with the given ID.
New in version 2.0.
- Parameters:
channel_id (
int
) – The ID to search for.- Returns:
The returned channel or thread or
None
if not found.- Return type:
Optional[Union[
Thread
,abc.GuildChannel
]]
- get_channel(channel_id, /)[source]¶
Returns a channel with the given ID.
Note
This does not search for threads.
- Parameters:
channel_id (
int
) – The ID to search for.- Returns:
The returned channel or
None
if not found.- Return type:
Optional[
abc.GuildChannel
]
- property system_channel[source]¶
Returns the guild’s channel used for system messages.
If no channel is set, then this returns
None
.- Type:
Optional[
TextChannel
]
- property rules_channel[source]¶
Returns the guild’s channel used for the rules. The guild must be a Community guild.
If no channel is set, then this returns
None
.New in version 1.3.
- Type:
Optional[
TextChannel
]
- property public_updates_channel[source]¶
Returns the guild’s channel where admins and moderators of the guild receive notices from Discord. The guild must be a Community guild.
If no channel is set, then this returns
None
.New in version 1.4.
- Type:
Optional[
TextChannel
]
- property safety_alerts_channel[source]¶
Returns the guild’s channel where admins and moderators of the guild receive safety alerts from Discord. The guild must be a Community guild.
If no channel is set, then this returns
None
.New in version 2.9.
- Type:
Optional[
TextChannel
]
- property emoji_limit[source]¶
The maximum number of emoji slots this guild has.
Premium emojis (i.e. those associated with subscription roles) count towards a separate limit of 25.
- Type:
- property sticker_limit[source]¶
The maximum number of sticker slots this guild has.
New in version 2.0.
- Type:
- property bitrate_limit[source]¶
The maximum bitrate for voice channels this guild can have. For stage channels, the maximum bitrate is 64000.
- Type:
- property filesize_limit[source]¶
The maximum number of bytes files can have when uploaded to this guild.
- Type:
A list of members who have “boosted” this guild.
- Type:
List[
Member
]
- property roles[source]¶
Returns a
list
of the guild’s roles in hierarchy order.The first element of this list will be the lowest role in the hierarchy.
- Type:
List[
Role
]
Gets the premium subscriber role, AKA “boost” role, in this guild, if any.
New in version 1.6.
- Type:
Optional[
Role
]
- property self_role[source]¶
Gets the role associated with this client’s user, if any.
New in version 1.6.
- Type:
Optional[
Role
]
- property stage_instances[source]¶
Returns a
list
of the guild’s stage instances that are currently running.New in version 2.0.
- Type:
List[
StageInstance
]
- get_stage_instance(stage_instance_id, /)[source]¶
Returns a stage instance with the given ID.
New in version 2.0.
- Parameters:
stage_instance_id (
int
) – The ID to search for.- Returns:
The stage instance or
None
if not found.- Return type:
Optional[
StageInstance
]
- property scheduled_events[source]¶
Returns a
list
of existing guild scheduled events.New in version 2.3.
- Type:
List[
GuildScheduledEvent
]
- get_scheduled_event(event_id, /)[source]¶
Returns a guild scheduled event with the given ID.
New in version 2.3.
- Parameters:
event_id (
int
) – The ID to search for.- Returns:
The guild scheduled event or
None
if not found.- Return type:
Optional[
GuildScheduledEvent
]
- property splash[source]¶
Returns the guild’s invite splash asset, if available.
- Type:
Optional[
Asset
]
- property discovery_splash[source]¶
Returns the guild’s discovery splash asset, if available.
- Type:
Optional[
Asset
]
- property member_count[source]¶
Returns the true member count regardless of it being loaded fully or not.
Warning
Due to a Discord limitation, in order for this attribute to remain up-to-date and accurate, it requires
Intents.members
to be specified.- Type:
- property region[source]¶
The region the guild belongs on.
Deprecated since version 2.5: VoiceRegion is no longer set on the guild, and is set on the individual voice channels instead. See
VoiceChannel.rtc_region
andStageChannel.rtc_region
instead.Changed in version 2.5: No longer a
VoiceRegion
instance.- Type:
Optional[
str
]
- property chunked[source]¶
Whether the guild is “chunked”.
A chunked guild means that
member_count
is equal to the number of members stored in the internalmembers
cache.If this value returns
False
, then you should request for offline members.- Type:
- get_member_named(name, /)[source]¶
Returns the first member found that matches the name provided.
The lookup strategy is as follows (in order):
Lookup by nickname.
Lookup by global name.
Lookup by username.
The name can have an optional discriminator argument, e.g. “Jake#0001”, in which case it will be treated as a username + discriminator combo (note: this only works with usernames, not nicknames).
If no member is found,
None
is returned.Changed in version 2.9: Now takes
User.global_name
into account.
- await create_text_channel(name, *, reason=None, category=None, position=..., topic=..., slowmode_delay=..., default_thread_slowmode_delay=..., default_auto_archive_duration=..., nsfw=..., news=..., overwrites=...)[source]¶
This function is a coroutine.
Creates a
TextChannel
for the guild.You need
manage_channels
permission to create the channel.The
overwrites
parameter can be used to create a ‘secret’ channel upon creation. This parameter expects adict
of overwrites with the target (either aMember
or aRole
) as the key and aPermissionOverwrite
as the value.Note
Creating a channel of a specified position will not update the position of other channels to follow suit. A follow-up call to
edit()
will be required to update the position of the channel in the channel list.Changed in version 2.6: Raises
TypeError
instead ofInvalidArgument
.Examples
Creating a basic channel:
channel = await guild.create_text_channel('cool-channel')
Creating a “secret” channel:
overwrites = { guild.default_role: disnake.PermissionOverwrite(view_channel=False), guild.me: disnake.PermissionOverwrite(view_channel=True) } channel = await guild.create_text_channel('secret', overwrites=overwrites)
- Parameters:
name (
str
) – The channel’s name.overwrites (Dict[Union[
Role
,Member
],PermissionOverwrite
]) – Adict
of target (either a role or a member) toPermissionOverwrite
to apply upon creation of a channel. Useful for creating secret channels.category (Optional[
abc.Snowflake
]) – The category to place the newly created channel under. The permissions will be automatically synced to category if no overwrites are provided.position (
int
) – The position in the channel list. This is a number that starts at 0. e.g. the top channel is position 0.topic (Optional[
str
]) – The channel’s topic.slowmode_delay (
int
) – Specifies the slowmode rate limit for users in this channel, in seconds. A value of0
disables slowmode. The maximum value possible is21600
. If not provided, slowmode is disabled.default_thread_slowmode_delay (
int
) –Specifies the slowmode rate limit at which users can send messages in newly created threads in this channel, in seconds. A value of
0
disables slowmode by default. The maximum value possible is21600
. If not provided, slowmode is disabled.New in version 2.8.
default_auto_archive_duration (Union[
int
,ThreadArchiveDuration
]) –The default auto archive duration in minutes for threads created in this channel. Must be one of
60
,1440
,4320
, or10080
.New in version 2.5.
nsfw (
bool
) – Whether to mark the channel as NSFW.news (
bool
) –Whether to make a news channel. News channels are text channels that can be followed. This is only available to guilds that contain
NEWS
inGuild.features
.New in version 2.5.
reason (Optional[
str
]) – The reason for creating this channel. Shows up on the audit log.
- Raises:
Forbidden – You do not have the proper permissions to create this channel.
HTTPException – Creating the channel failed.
TypeError – The permission overwrite information is not in proper form.
- Returns:
The channel that was just created.
- Return type:
- await create_voice_channel(name, *, category=None, position=..., bitrate=..., user_limit=..., rtc_region=..., video_quality_mode=..., nsfw=..., slowmode_delay=..., overwrites=..., reason=None)[source]¶
This function is a coroutine.
This is similar to
create_text_channel()
except makes aVoiceChannel
instead.Changed in version 2.6: Raises
TypeError
instead ofInvalidArgument
.- Parameters:
name (
str
) – The channel’s name.overwrites (Dict[Union[
Role
,Member
],PermissionOverwrite
]) – Adict
of target (either a role or a member) toPermissionOverwrite
to apply upon creation of a channel. Useful for creating secret channels.category (Optional[
abc.Snowflake
]) – The category to place the newly created channel under. The permissions will be automatically synced to category if no overwrites are provided.position (
int
) – The position in the channel list. This is a number that starts at 0. e.g. the top channel is position 0.bitrate (
int
) – The channel’s preferred audio bitrate in bits per second.user_limit (
int
) – The channel’s limit for number of members that can be in a voice channel.rtc_region (Optional[Union[
str
,VoiceRegion
]]) –The region for the voice channel’s voice communication. A value of
None
indicates automatic voice region detection.New in version 1.7.
video_quality_mode (
VideoQualityMode
) –The camera video quality for the voice channel’s participants.
New in version 2.0.
nsfw (
bool
) –Whether to mark the channel as NSFW.
New in version 2.5.
slowmode_delay (
int
) –Specifies the slowmode rate limit for users in this channel, in seconds. A value of
0
disables slowmode. The maximum value possible is21600
. If not provided, slowmode is disabled.New in version 2.6.
reason (Optional[
str
]) – The reason for creating this channel. Shows up on the audit log.
- Raises:
Forbidden – You do not have the proper permissions to create this channel.
HTTPException – Creating the channel failed.
TypeError – The permission overwrite information is not in proper form.
- Returns:
The channel that was just created.
- Return type:
- await create_stage_channel(name, *, topic=..., position=..., bitrate=..., user_limit=..., rtc_region=..., video_quality_mode=..., overwrites=..., category=None, nsfw=..., slowmode_delay=..., reason=None)[source]¶
This function is a coroutine.
This is similar to
create_text_channel()
except makes aStageChannel
instead.New in version 1.7.
Changed in version 2.6: Raises
TypeError
instead ofInvalidArgument
.- Parameters:
name (
str
) – The channel’s name.topic (Optional[
str
]) –The channel’s topic.
Changed in version 2.5: This is no longer required to be provided.
overwrites (Dict[Union[
Role
,Member
],PermissionOverwrite
]) – Adict
of target (either a role or a member) toPermissionOverwrite
to apply upon creation of a channel. Useful for creating secret channels.category (Optional[
abc.Snowflake
]) – The category to place the newly created channel under. The permissions will be automatically synced to category if no overwrites are provided.position (
int
) – The position in the channel list. This is a number that starts at 0. e.g. the top channel is position 0.bitrate (
int
) –The channel’s preferred audio bitrate in bits per second.
New in version 2.6.
rtc_region (Optional[Union[
str
,VoiceRegion
]]) –The region for the stage channel’s voice communication. A value of
None
indicates automatic voice region detection.New in version 2.5.
nsfw (
bool
) –Whether to mark the channel as NSFW.
New in version 2.9.
slowmode_delay (
int
) –Specifies the slowmode rate limit for users in this channel, in seconds. A value of
0
disables slowmode. The maximum value possible is21600
. If not provided, slowmode is disabled.New in version 2.9.
- reason: Optional[
str
] The reason for creating this channel. Shows up on the audit log.
- Raises:
Forbidden – You do not have the proper permissions to create this channel.
HTTPException – Creating the channel failed.
TypeError – The permission overwrite information is not in proper form.
- Returns:
The channel that was just created.
- Return type:
- await create_forum_channel(name, *, topic=None, category=None, position=..., slowmode_delay=..., default_thread_slowmode_delay=..., default_auto_archive_duration=None, nsfw=..., overwrites=..., available_tags=None, default_reaction=None, default_sort_order=None, default_layout=None, reason=None)[source]¶
This function is a coroutine.
This is similar to
create_text_channel()
except makes aForumChannel
instead.New in version 2.5.
Changed in version 2.6: Raises
TypeError
instead ofInvalidArgument
.- Parameters:
name (
str
) – The channel’s name.topic (Optional[
str
]) – The channel’s topic.category (Optional[
abc.Snowflake
]) – The category to place the newly created channel under. The permissions will be automatically synced to category if no overwrites are provided.position (
int
) – The position in the channel list. This is a number that starts at 0. e.g. the top channel is position 0.slowmode_delay (
int
) – Specifies the slowmode rate limit at which users can create threads in this channel, in seconds. A value of0
disables slowmode. The maximum value possible is21600
. If not provided, slowmode is disabled.default_thread_slowmode_delay (
int
) –Specifies the slowmode rate limit at which users can send messages in newly created threads in this channel, in seconds. A value of
0
disables slowmode by default. The maximum value possible is21600
. If not provided, slowmode is disabled.New in version 2.6.
default_auto_archive_duration (Union[
int
,ThreadArchiveDuration
]) – The default auto archive duration in minutes for threads created in this channel. Must be one of60
,1440
,4320
, or10080
.nsfw (
bool
) – Whether to mark the channel as NSFW.overwrites (Dict[Union[
Role
,Member
],PermissionOverwrite
]) – Adict
of target (either a role or a member) toPermissionOverwrite
to apply upon creation of a channel. Useful for creating secret channels.available_tags (Optional[Sequence[
ForumTag
]]) –The tags available for threads in this channel.
New in version 2.6.
default_reaction (Optional[Union[
str
,Emoji
,PartialEmoji
]]) –The default emoji shown for reacting to threads.
New in version 2.6.
default_sort_order (Optional[
ThreadSortOrder
]) –The default sort order of threads in this channel.
New in version 2.6.
default_layout (
ThreadLayout
) –The default layout of threads in this channel.
New in version 2.10.
reason (Optional[
str
]) – The reason for creating this channel. Shows up on the audit log.
- Raises:
Forbidden – You do not have the proper permissions to create this channel.
HTTPException – Creating the channel failed.
TypeError – The permission overwrite information is not in proper form.
- Returns:
The channel that was just created.
- Return type:
- await create_media_channel(name, *, topic=None, category=None, position=..., slowmode_delay=..., default_thread_slowmode_delay=..., default_auto_archive_duration=None, nsfw=..., overwrites=..., available_tags=None, default_reaction=None, default_sort_order=None, reason=None)[source]¶
This function is a coroutine.
This is similar to
create_text_channel()
except makes aMediaChannel
instead.New in version 2.10.
- Parameters:
name (
str
) – The channel’s name.topic (Optional[
str
]) – The channel’s topic.category (Optional[
abc.Snowflake
]) – The category to place the newly created channel under. The permissions will be automatically synced to category if no overwrites are provided.position (
int
) – The position in the channel list. This is a number that starts at 0. e.g. the top channel is position 0.slowmode_delay (
int
) – Specifies the slowmode rate limit at which users can create threads in this channel, in seconds. A value of0
disables slowmode. The maximum value possible is21600
. If not provided, slowmode is disabled.default_thread_slowmode_delay (
int
) – Specifies the slowmode rate limit at which users can send messages in newly created threads in this channel, in seconds. A value of0
disables slowmode by default. The maximum value possible is21600
. If not provided, slowmode is disabled.default_auto_archive_duration (Union[
int
,ThreadArchiveDuration
]) – The default auto archive duration in minutes for threads created in this channel. Must be one of60
,1440
,4320
, or10080
.nsfw (
bool
) – Whether to mark the channel as NSFW.overwrites (Dict[Union[
Role
,Member
],PermissionOverwrite
]) – Adict
of target (either a role or a member) toPermissionOverwrite
to apply upon creation of a channel. Useful for creating secret channels.available_tags (Optional[Sequence[
ForumTag
]]) – The tags available for threads in this channel.default_reaction (Optional[Union[
str
,Emoji
,PartialEmoji
]]) – The default emoji shown for reacting to threads.default_sort_order (Optional[
ThreadSortOrder
]) – The default sort order of threads in this channel.reason (Optional[
str
]) – The reason for creating this channel. Shows up on the audit log.
- Raises:
Forbidden – You do not have the proper permissions to create this channel.
HTTPException – Creating the channel failed.
TypeError – The permission overwrite information is not in proper form.
- Returns:
The channel that was just created.
- Return type:
- await create_category(name, *, overwrites=..., reason=None, position=...)[source]¶
This function is a coroutine.
Same as
create_text_channel()
except makes aCategoryChannel
instead.Note
The
category
parameter is not supported in this function since categories cannot have categories.Changed in version 2.6: Raises
TypeError
instead ofInvalidArgument
.- Parameters:
name (
str
) – The category’s name.overwrites (Dict[Union[
Role
,Member
],PermissionOverwrite
]) – Adict
of target (either a role or a member) toPermissionOverwrite
which can be synced to channels.position (
int
) – The position in the channel list. This is a number that starts at 0. e.g. the top channel is position 0.reason (Optional[
str
]) – The reason for creating this category. Shows up on the audit log.
- Raises:
Forbidden – You do not have the proper permissions to create this channel.
HTTPException – Creating the channel failed.
TypeError – The permission overwrite information is not in proper form.
- Returns:
The channel that was just created.
- Return type:
- await create_category_channel(name, *, overwrites=..., reason=None, position=...)[source]¶
This function is a coroutine.
Same as
create_text_channel()
except makes aCategoryChannel
instead.Note
The
category
parameter is not supported in this function since categories cannot have categories.Changed in version 2.6: Raises
TypeError
instead ofInvalidArgument
.- Parameters:
name (
str
) – The category’s name.overwrites (Dict[Union[
Role
,Member
],PermissionOverwrite
]) – Adict
of target (either a role or a member) toPermissionOverwrite
which can be synced to channels.position (
int
) – The position in the channel list. This is a number that starts at 0. e.g. the top channel is position 0.reason (Optional[
str
]) – The reason for creating this category. Shows up on the audit log.
- Raises:
Forbidden – You do not have the proper permissions to create this channel.
HTTPException – Creating the channel failed.
TypeError – The permission overwrite information is not in proper form.
- Returns:
The channel that was just created.
- Return type:
- await leave()[source]¶
This function is a coroutine.
Leaves the guild.
Note
You cannot leave the guild that you own, you must delete it instead via
delete()
.- Raises:
HTTPException – Leaving the guild failed.
- await delete()[source]¶
This function is a coroutine.
Deletes the guild. You must be the guild owner to delete the guild.
- Raises:
HTTPException – Deleting the guild failed.
Forbidden – You do not have permissions to delete the guild.
- await edit(*, reason=..., name=..., description=..., icon=..., banner=..., splash=..., discovery_splash=..., community=..., invites_disabled=..., raid_alerts_disabled=..., afk_channel=..., owner=..., afk_timeout=..., default_notifications=..., verification_level=..., explicit_content_filter=..., vanity_code=..., system_channel=..., system_channel_flags=..., preferred_locale=..., rules_channel=..., public_updates_channel=..., safety_alerts_channel=..., premium_progress_bar_enabled=...)[source]¶
This function is a coroutine.
Edits the guild.
You must have
manage_guild
permission to use this.Changed in version 1.4: The rules_channel and public_updates_channel keyword-only parameters were added.
Changed in version 2.0: The discovery_splash and community keyword-only parameters were added.
Changed in version 2.0: The newly updated guild is returned.
Changed in version 2.5: Removed the
region
parameter. UseVoiceChannel.edit()
orStageChannel.edit()
withrtc_region
instead.Changed in version 2.6: Raises
TypeError
orValueError
instead ofInvalidArgument
.- Parameters:
name (
str
) – The new name of the guild.description (Optional[
str
]) – The new description of the guild. Could beNone
for no description. This is only available to guilds that containCOMMUNITY
inGuild.features
.icon (Optional[Union[
bytes
,Asset
,Emoji
,PartialEmoji
,StickerItem
,Sticker
]]) –The new guild icon. Only PNG/JPG is supported. GIF is only available to guilds that contain
ANIMATED_ICON
inGuild.features
. Could beNone
to denote removal of the icon.Changed in version 2.5: Now accepts various resource types in addition to
bytes
.banner (Optional[Union[
bytes
,Asset
,Emoji
,PartialEmoji
,StickerItem
,Sticker
]]) –The new guild banner. GIF is only available to guilds that contain
ANIMATED_BANNER
inGuild.features
. Could beNone
to denote removal of the banner. This is only available to guilds that containBANNER
inGuild.features
.Changed in version 2.5: Now accepts various resource types in addition to
bytes
.splash (Optional[Union[
bytes
,Asset
,Emoji
,PartialEmoji
,StickerItem
,Sticker
]]) –The new guild invite splash. Only PNG/JPG is supported. Could be
None
to denote removing the splash. This is only available to guilds that containINVITE_SPLASH
inGuild.features
.Changed in version 2.5: Now accepts various resource types in addition to
bytes
.discovery_splash (Optional[Union[
bytes
,Asset
,Emoji
,PartialEmoji
,StickerItem
,Sticker
]]) –The new guild discovery splash. Only PNG/JPG is supported. Could be
None
to denote removing the splash. This is only available to guilds that containDISCOVERABLE
inGuild.features
.Changed in version 2.5: Now accepts various resource types in addition to
bytes
.community (
bool
) – Whether the guild should be a Community guild. If set toTrue
, bothrules_channel
andpublic_updates_channel
parameters are required.invites_disabled (
bool
) –Whether the guild has paused invites, preventing new users from joining.
This is only available to guilds that contain
COMMUNITY
inGuild.features
.This cannot be changed at the same time as the
community
feature due a Discord API limitation.New in version 2.6.
raid_alerts_disabled (
bool
) –Whether the guild has disabled join raid alerts.
This is only available to guilds that contain
COMMUNITY
inGuild.features
.This cannot be changed at the same time as the
community
feature due a Discord API limitation.New in version 2.9.
afk_channel (Optional[
VoiceChannel
]) – The new channel that is the AFK channel. Could beNone
for no AFK channel.afk_timeout (
int
) – The number of seconds until someone is moved to the AFK channel. This can be set to60
,300
,900
,1800
, and3600
.owner (
Member
) – The new owner of the guild to transfer ownership to. Note that you must be owner of the guild to do this.verification_level (
VerificationLevel
) – The new verification level for the guild.default_notifications (
NotificationLevel
) – The new default notification level for the guild.explicit_content_filter (
ContentFilter
) – The new explicit content filter for the guild.vanity_code (
str
) – The new vanity code for the guild.system_channel (Optional[
TextChannel
]) – The new channel that is used for the system channel. Could beNone
for no system channel.system_channel_flags (
SystemChannelFlags
) – The new system channel settings to use with the new system channel.preferred_locale (
Locale
) –The new preferred locale for the guild. Used as the primary language in the guild.
rules_channel (Optional[
TextChannel
]) – The new channel that is used for rules. This is only available to guilds that containCOMMUNITY
inGuild.features
. Could beNone
for no rules channel.public_updates_channel (Optional[
TextChannel
]) – The new channel that is used for public updates from Discord. This is only available to guilds that containCOMMUNITY
inGuild.features
. Could beNone
for no public updates channel.safety_alerts_channel (Optional[
TextChannel
]) –The new channel that is used for safety alerts. This is only available to guilds that contain
COMMUNITY
inGuild.features
. Could beNone
for no safety alerts channel.New in version 2.9.
premium_progress_bar_enabled (
bool
) – Whether the server boost progress bar is enabled.reason (Optional[
str
]) – The reason for editing this guild. Shows up on the audit log.
- Raises:
NotFound – At least one of the assets (
icon
,banner
,splash
ordiscovery_splash
) couldn’t be found.Forbidden – You do not have permissions to edit the guild.
HTTPException – Editing the guild failed.
TypeError – At least one of the assets (
icon
,banner
,splash
ordiscovery_splash
) is a lottie sticker (seeSticker.read()
), or one of the parametersdefault_notifications
,verification_level
,explicit_content_filter
, orsystem_channel_flags
was of the incorrect type.ValueError –
community
was set without setting bothrules_channel
andpublic_updates_channel
parameters, or if you are not the owner of the guild and request an ownership transfer, or the image format passed in toicon
is invalid, or bothcommunity
andinvites_disabled` or ``raid_alerts_disabled
were provided.
- Returns:
The newly updated guild. Note that this has the same limitations as mentioned in
Client.fetch_guild()
and may not have full data.- Return type:
- await fetch_channels()[source]¶
This function is a coroutine.
Retrieves all
abc.GuildChannel
that the guild has.Note
This method is an API call. For general usage, consider
channels
instead.New in version 1.2.
- Raises:
InvalidData – An unknown channel type was received from Discord.
HTTPException – Retrieving the channels failed.
- Returns:
All channels that the guild has.
- Return type:
Sequence[
abc.GuildChannel
]
- await active_threads()[source]¶
This function is a coroutine.
Returns a list of active
Thread
that the client can access.This includes both private and public threads.
New in version 2.0.
- Raises:
HTTPException – The request to get the active threads failed.
- Returns:
The active threads.
- Return type:
List[
Thread
]
- await fetch_scheduled_events(*, with_user_count=False)[source]¶
This function is a coroutine.
Retrieves a list of all
GuildScheduledEvent
instances that the guild has.New in version 2.3.
- Parameters:
with_user_count (
bool
) – Whether to include number of users subscribed to each event.- Raises:
HTTPException – Retrieving the guild scheduled events failed.
- Returns:
The existing guild scheduled events.
- Return type:
List[
GuildScheduledEvent
]
- await fetch_scheduled_event(event_id, *, with_user_count=False)[source]¶
This function is a coroutine.
Retrieves a
GuildScheduledEvent
with the given ID.New in version 2.3.
- Parameters:
- Raises:
HTTPException – Retrieving the guild scheduled event failed.
- Returns:
The guild scheduled event.
- Return type:
- await create_scheduled_event(*, name, scheduled_start_time, channel=..., entity_type=..., scheduled_end_time=..., privacy_level=..., entity_metadata=..., description=..., image=..., reason=None)[source]¶
This function is a coroutine.
Creates a
GuildScheduledEvent
.You must have
manage_events
permission to do this.Based on the channel/entity type, there are different restrictions regarding other parameter values, as shown in this table:
channel
entity_type
scheduled_end_time
entity_metadata
with locationabc.Snowflake
withtype
attribute beingChannelType.voice
voice
(set automatically)optional
unset
abc.Snowflake
withtype
attribute beingChannelType.stage_voice
stage_instance
(set automatically)optional
unset
abc.Snowflake
with missing/othertype
attributerequired
optional
unset
None
external
(set automatically)required
required
unset
required
required
New in version 2.3.
Changed in version 2.6: Now raises
TypeError
instead ofValueError
for invalid parameter types.Changed in version 2.6: Removed
channel_id
parameter in favor ofchannel
.Changed in version 2.6: Naive datetime parameters are now assumed to be in the local timezone instead of UTC.
Changed in version 2.6: Infer
entity_type
from channel if provided.- Parameters:
name (
str
) – The name of the guild scheduled event.description (
str
) – The description of the guild scheduled event.image (Union[
bytes
,Asset
,Emoji
,PartialEmoji
,StickerItem
,Sticker
]) –The cover image of the guild scheduled event.
New in version 2.4.
Changed in version 2.5: Now accepts various resource types in addition to
bytes
.channel (Optional[
abc.Snowflake
]) –The channel in which the guild scheduled event will be hosted. Passing in None assumes the
entity_type
to beGuildScheduledEventEntityType.external
New in version 2.6.
privacy_level (
GuildScheduledEventPrivacyLevel
) – The privacy level of the guild scheduled event.scheduled_start_time (
datetime.datetime
) – The time to schedule the guild scheduled event. If the datetime is naive, it is assumed to be local time.scheduled_end_time (Optional[
datetime.datetime
]) – The time when the guild scheduled event is scheduled to end. If the datetime is naive, it is assumed to be local time.entity_type (
GuildScheduledEventEntityType
) – The entity type of the guild scheduled event.entity_metadata (
GuildScheduledEventMetadata
) – The entity metadata of the guild scheduled event.reason (Optional[
str
]) – The reason for creating the guild scheduled event. Shows up on the audit log.
- Raises:
NotFound – The
image
asset couldn’t be found.HTTPException – The request failed.
TypeError – The
image
asset is a lottie sticker (seeSticker.read()
), one ofentity_type
,privacy_level
, orentity_metadata
is not of the correct type, or theentity_type
was not provided and could not be assumed from thechannel
.
- Returns:
The newly created guild scheduled event.
- Return type:
- await welcome_screen()[source]¶
This function is a coroutine.
Retrieves the guild’s
WelcomeScreen
.Requires the
manage_guild
permission if the welcome screen is not enabled.Note
To determine whether the welcome screen is enabled, check for the presence of
WELCOME_SCREEN_ENABLED
inGuild.features
.New in version 2.5.
- Raises:
NotFound – The welcome screen is not set up, or you do not have permission to view it.
HTTPException – Retrieving the welcome screen failed.
- Returns:
The guild’s welcome screen.
- Return type:
- await edit_welcome_screen(*, enabled=..., channels=..., description=..., reason=None)[source]¶
This function is a coroutine.
This is a lower level method to
WelcomeScreen.edit()
that allows you to edit the welcome screen without fetching it and save an API request.This requires ‘COMMUNITY’ in
Guild.features
.New in version 2.5.
- Parameters:
enabled (
bool
) – Whether the welcome screen is enabled.description (Optional[
str
]) – The new guild description in the welcome screen.channels (Optional[List[
WelcomeScreenChannel
]]) – The new welcome channels.reason (Optional[
str
]) – The reason for editing the welcome screen. Shows up on the audit log.
- Raises:
Forbidden – You do not have permissions to change the welcome screen or the guild is not allowed to create welcome screens.
HTTPException – Editing the welcome screen failed.
TypeError –
channels
is not a list ofWelcomeScreenChannel
instances
- Returns:
The newly edited welcome screen.
- Return type:
- await fetch_member(member_id, /)[source]¶
This function is a coroutine.
Retrieves a
Member
with the given ID.Note
This method is an API call. If you have
Intents.members
and member cache enabled, considerget_member()
instead.- Parameters:
member_id (
int
) – The member’s ID to fetch from.- Raises:
NotFound – A member with this ID does not exist in the guild.
Forbidden – You do not have access to the guild.
HTTPException – Retrieving the member failed.
- Returns:
The member from the member ID.
- Return type:
- await fetch_ban(user)[source]¶
This function is a coroutine.
Retrieves the
BanEntry
for a user.You must have
ban_members
permission to use this.- Parameters:
user (
abc.Snowflake
) – The user to get ban information from.- Raises:
Forbidden – You do not have proper permissions to get the information.
NotFound – This user is not banned.
HTTPException – An error occurred while fetching the information.
- Returns:
The
BanEntry
object for the specified user.- Return type:
- await fetch_channel(channel_id, /)[source]¶
This function is a coroutine.
Retrieves a
abc.GuildChannel
orThread
with the given ID.Note
This method is an API call. For general usage, consider
get_channel_or_thread()
instead.New in version 2.0.
- Raises:
InvalidData – An unknown channel type was received from Discord or the guild the channel belongs to is not the same as the one in this object points to.
HTTPException – Retrieving the channel failed.
NotFound – Invalid Channel ID.
Forbidden – You do not have permission to fetch this channel.
- Returns:
The channel from the ID.
- Return type:
Union[
abc.GuildChannel
,Thread
]
- bans(*, limit=1000, before=None, after=None)[source]¶
Returns an
AsyncIterator
that enables receiving the destination’s bans.You must have the
ban_members
permission to get this information.Changed in version 2.5: Due to a breaking change in Discord’s API, this now returns an
AsyncIterator
instead of alist
.Examples
Usage
counter = 0 async for ban in guild.bans(limit=200): if not ban.user.bot: counter += 1
Flattening into a list:
bans = await guild.bans(limit=123).flatten() # bans is now a list of BanEntry...
All parameters are optional.
- Parameters:
limit (Optional[
int
]) – The number of bans to retrieve. IfNone
, it retrieves every ban in the guild. Note, however, that this would make it a slow operation. Defaults to 1000.before (Optional[
Snowflake
]) – Retrieve bans before this user.after (Optional[
Snowflake
]) – Retrieve bans after this user.
- Raises:
Forbidden – You do not have permissions to get the bans.
HTTPException – An error occurred while fetching the bans.
- Yields:
BanEntry
– The ban with the ban data parsed.
- await prune_members(*, days, compute_prune_count=True, roles=..., reason=None)[source]¶
This function is a coroutine.
Prunes the guild from its inactive members.
The inactive members are denoted if they have not logged on in
days
number of days and they have no roles.You must have the
manage_guild
andkick_members
permissions to use this.To check how many members you would prune without actually pruning, see the
estimate_pruned_members()
function.To prune members that have specific roles see the
roles
parameter.Changed in version 1.4: The
roles
keyword-only parameter was added.Changed in version 2.6: Raises
TypeError
instead ofInvalidArgument
.- Parameters:
days (
int
) – The number of days before counting as inactive.compute_prune_count (
bool
) – Whether to compute the prune count. This defaults toTrue
which makes it prone to timeouts in very large guilds. In order to prevent timeouts, you must set this toFalse
. If this is set toFalse
, then this function will always returnNone
.roles (List[
abc.Snowflake
]) – A list ofabc.Snowflake
that represent roles to include in the pruning process. If a member has a role that is not specified, they’ll be excluded.reason (Optional[
str
]) – The reason for doing this action. Shows up on the audit log.
- Raises:
Forbidden – You do not have permissions to prune members.
HTTPException – An error occurred while pruning members.
TypeError – An integer was not passed for
days
.
- Returns:
The number of members pruned. If
compute_prune_count
isFalse
then this returnsNone
.- Return type:
Optional[
int
]
- await templates()[source]¶
This function is a coroutine.
Gets the list of templates from this guild.
You must have
manage_guild
permission to use this.New in version 1.7.
- await webhooks()[source]¶
This function is a coroutine.
Gets the list of webhooks from this guild.
You must have
manage_webhooks
permission to use this.
- await estimate_pruned_members(*, days, roles=...)[source]¶
This function is a coroutine.
Similar to
prune_members()
except instead of actually pruning members, it returns how many members it would prune from the guild had it been called.Changed in version 2.6: Raises
TypeError
instead ofInvalidArgument
.- Parameters:
days (
int
) – The number of days before counting as inactive.roles (List[
abc.Snowflake
]) –A list of
abc.Snowflake
that represent roles to include in the estimate. If a member has a role that is not specified, they’ll be excluded.New in version 1.7.
- Raises:
Forbidden – You do not have permissions to prune members.
HTTPException – An error occurred while fetching the prune members estimate.
TypeError – An integer was not passed for
days
.
- Returns:
The number of members estimated to be pruned.
- Return type:
- await invites()[source]¶
This function is a coroutine.
Returns a list of all active instant invites from the guild.
You must have
manage_guild
permission to use this.Note
This method does not include the guild’s vanity URL invite. To get the vanity URL
Invite
, refer toGuild.vanity_invite()
.- Raises:
Forbidden – You do not have proper permissions to get the information.
HTTPException – An error occurred while fetching the information.
- Returns:
The list of invites that are currently active.
- Return type:
List[
Invite
]
- await create_template(*, name, description=...)[source]¶
This function is a coroutine.
Creates a template for the guild.
You must have
manage_guild
permission to use this.New in version 1.7.
- await create_integration(*, type, id)[source]¶
This function is a coroutine.
Deprecated since version 2.5: No longer supported, bots cannot use this endpoint anymore.
Attaches an integration to the guild.
You must have
manage_guild
permission to use this.New in version 1.4.
- Parameters:
- Raises:
Forbidden – You do not have permission to create the integration.
HTTPException – The account could not be found.
- await integrations()[source]¶
This function is a coroutine.
Returns a list of all integrations attached to the guild.
You must have
manage_guild
permission to use this.New in version 1.4.
- Raises:
Forbidden – You do not have permission to create the integration.
HTTPException – Fetching the integrations failed.
- Returns:
The list of integrations that are attached to the guild.
- Return type:
List[
Integration
]
- await fetch_stickers()[source]¶
This function is a coroutine.
Retrieves a list of all
Sticker
s that the guild has.New in version 2.0.
Note
This method is an API call. For general usage, consider
stickers
instead.- Raises:
HTTPException – Retrieving the stickers failed.
- Returns:
The retrieved stickers.
- Return type:
List[
GuildSticker
]
- await fetch_sticker(sticker_id, /)[source]¶
This function is a coroutine.
Retrieves a custom
Sticker
from the guild.New in version 2.0.
Note
This method is an API call. For general usage, consider iterating over
stickers
instead.- Parameters:
sticker_id (
int
) – The sticker’s ID.- Raises:
NotFound – The sticker requested could not be found.
HTTPException – Retrieving the sticker failed.
- Returns:
The retrieved sticker.
- Return type:
- await create_sticker(*, name, description=None, emoji, file, reason=None)[source]¶
This function is a coroutine.
Creates a
Sticker
for the guild.You must have
manage_guild_expressions
permission to do this.New in version 2.0.
- Parameters:
name (
str
) – The sticker name. Must be at least 2 characters.description (Optional[
str
]) – The sticker’s description. You can passNone
or an empty string to not set a description.emoji (
str
) – The name of a unicode emoji that represents the sticker’s expression.file (
File
) – The file of the sticker to upload.reason (Optional[
str
]) – The reason for creating this sticker. Shows up on the audit log.
- Raises:
Forbidden – You are not allowed to create stickers.
HTTPException – An error occurred creating a sticker.
- Returns:
The newly created sticker.
- Return type:
- await delete_sticker(sticker, *, reason=None)[source]¶
This function is a coroutine.
Deletes the custom
Sticker
from the guild.You must have
manage_guild_expressions
permission to do this.New in version 2.0.
- Parameters:
sticker (
abc.Snowflake
) – The sticker you are deleting.reason (Optional[
str
]) – The reason for deleting this sticker. Shows up on the audit log.
- Raises:
Forbidden – You are not allowed to delete this sticker.
HTTPException – An error occurred deleting the sticker.
- await fetch_emojis()[source]¶
This function is a coroutine.
Retrieves all custom
Emoji
s that the guild has.Note
This method is an API call. For general usage, consider
emojis
instead.- Raises:
HTTPException – Retrieving the emojis failed.
- Returns:
The retrieved emojis.
- Return type:
List[
Emoji
]
- await fetch_emoji(emoji_id, /)[source]¶
This function is a coroutine.
Retrieves a custom
Emoji
from the guild.Note
This method is an API call. For general usage, consider iterating over
emojis
instead.- Parameters:
emoji_id (
int
) – The emoji’s ID.- Raises:
NotFound – The emoji requested could not be found.
HTTPException – An error occurred fetching the emoji.
- Returns:
The retrieved emoji.
- Return type:
- await create_custom_emoji(*, name, image, roles=..., reason=None)[source]¶
This function is a coroutine.
Creates a custom
Emoji
for the guild.Depending on the boost level of your guild (which can be obtained via
premium_tier
), the amount of custom emojis that can be created changes:Boost level
Max custom emoji limit
0
50
1
100
2
150
3
250
Emojis with subscription roles (see
roles
below) are considered premium emoji, and count towards a separate limit of 25 emojis.You must have
manage_guild_expressions
permission to do this.- Parameters:
name (
str
) – The emoji name. Must be at least 2 characters.image (Union[
bytes
,Asset
,Emoji
,PartialEmoji
,StickerItem
,Sticker
]) –The image data of the emoji. Only JPG, PNG and GIF images are supported.
Changed in version 2.5: Now accepts various resource types in addition to
bytes
.roles (List[
Role
]) –A list of roles that can use this emoji. Leave empty to make it available to everyone.
An emoji cannot have both subscription roles (see
RoleTags.integration_id
) and non-subscription roles, and emojis can’t be converted between premium and non-premium after creation.reason (Optional[
str
]) – The reason for creating this emoji. Shows up on the audit log.
- Raises:
NotFound – The
image
asset couldn’t be found.Forbidden – You are not allowed to create emojis.
HTTPException – An error occurred creating an emoji.
TypeError – The
image
asset is a lottie sticker (seeSticker.read()
).ValueError – Wrong image format passed for
image
.
- Returns:
The newly created emoji.
- Return type:
- await delete_emoji(emoji, *, reason=None)[source]¶
This function is a coroutine.
Deletes the custom
Emoji
from the guild.You must have
manage_guild_expressions
permission to do this.- Parameters:
emoji (
abc.Snowflake
) – The emoji you are deleting.reason (Optional[
str
]) – The reason for deleting this emoji. Shows up on the audit log.
- Raises:
Forbidden – You are not allowed to delete this emoji.
HTTPException – An error occurred deleting the emoji.
- await fetch_role(role_id, /)[source]¶
This function is a coroutine.
Retrieve a
Role
.Note
This method is an API call. For general usage, consider
get_role()
orroles
instead.New in version 2.10.
- Parameters:
role_id (
int
) – The ID of the role to retrieve.- Raises:
NotFound – The role requested could not be found.
HTTPException – Retrieving the role failed.
- Returns:
The retrieved role.
- Return type:
- await fetch_roles()[source]¶
This function is a coroutine.
Retrieves all
Role
that the guild has.Note
This method is an API call. For general usage, consider
roles
instead.New in version 1.3.
- Raises:
HTTPException – Retrieving the roles failed.
- Returns:
All roles that the guild has.
- Return type:
List[
Role
]
- await get_or_fetch_member(member_id, *, strict=False)[source]¶
This function is a coroutine.
Tries to get the member from the cache. If it fails, fetches the member from the API and caches it.
If you want to make a bulk get-or-fetch call, use
get_or_fetch_members()
.This only propagates exceptions when the
strict
parameter is enabled.- Parameters:
member_id (
int
) – The ID to search for.strict (
bool
) – Whether to propagate exceptions fromfetch_member()
instead of returningNone
in case of failure (e.g. if the member wasn’t found). Defaults toFalse
.
- Returns:
The member with the given ID, or
None
if not found andstrict
is set toFalse
.- Return type:
Optional[
Member
]
- await getch_member(member_id, *, strict=False)[source]¶
This function is a coroutine.
Tries to get the member from the cache. If it fails, fetches the member from the API and caches it.
If you want to make a bulk get-or-fetch call, use
get_or_fetch_members()
.This only propagates exceptions when the
strict
parameter is enabled.- Parameters:
member_id (
int
) – The ID to search for.strict (
bool
) – Whether to propagate exceptions fromfetch_member()
instead of returningNone
in case of failure (e.g. if the member wasn’t found). Defaults toFalse
.
- Returns:
The member with the given ID, or
None
if not found andstrict
is set toFalse
.- Return type:
Optional[
Member
]
- await create_role(*, name=..., permissions=..., color=..., colour=..., hoist=..., icon=..., emoji=..., mentionable=..., reason=None)[source]¶
This function is a coroutine.
Creates a
Role
for the guild.All fields are optional.
You must have
manage_roles
permission to do this.Changed in version 1.6: Can now pass
int
tocolour
keyword-only parameter.Changed in version 2.6: Raises
TypeError
instead ofInvalidArgument
.- Parameters:
name (
str
) – The role name. Defaults to ‘new role’.permissions (
Permissions
) – The permissions the role should have. Defaults to no permissions.colour (Union[
Colour
,int
]) – The colour for the role. Defaults toColour.default()
. This is aliased tocolor
as well.hoist (
bool
) – Whether the role should be shown separately in the member list. Defaults toFalse
.icon (Union[
bytes
,Asset
,Emoji
,PartialEmoji
,StickerItem
,Sticker
]) –The role’s icon image (if the guild has the
ROLE_ICONS
feature).Changed in version 2.5: Now accepts various resource types in addition to
bytes
.emoji (
str
) – The role’s unicode emoji.mentionable (
bool
) – Whether the role should be mentionable by others. Defaults toFalse
.reason (Optional[
str
]) – The reason for creating this role. Shows up on the audit log.
- Raises:
NotFound – The
icon
asset couldn’t be found.Forbidden – You do not have permissions to create the role.
HTTPException – Creating the role failed.
TypeError – An invalid keyword argument was given, or the
icon
asset is a lottie sticker (seeSticker.read()
).
- Returns:
The newly created role.
- Return type:
- await edit_role_positions(positions, *, reason=None)[source]¶
This function is a coroutine.
Bulk edits a list of
Role
in the guild.You must have
manage_roles
permission to do this.New in version 1.4.
Changed in version 2.6: Raises
TypeError
instead ofInvalidArgument
.Example:
positions = { bots_role: 1, # penultimate role tester_role: 2, admin_role: 6 } await guild.edit_role_positions(positions=positions)
- Parameters:
- Raises:
Forbidden – You do not have permissions to move the roles.
HTTPException – Moving the roles failed.
TypeError – An invalid keyword argument was given.
- Returns:
A list of all the roles in the guild.
- Return type:
List[
Role
]
- await kick(user, *, reason=None)[source]¶
This function is a coroutine.
Kicks a user from the guild.
The user must meet the
abc.Snowflake
abc.You must have
kick_members
permission to do this.- Parameters:
user (
abc.Snowflake
) – The user to kick from the guild.reason (Optional[
str
]) – The reason for kicking this user. Shows up on the audit log.
- Raises:
Forbidden – You do not have the proper permissions to kick.
HTTPException – Kicking failed.
- await ban(user, *, clean_history_duration=..., delete_message_days=..., reason=None)[source]¶
This function is a coroutine.
Bans a user from the guild.
The user must meet the
abc.Snowflake
abc.You must have
ban_members
permission to do this.- Parameters:
user (
abc.Snowflake
) – The user to ban from the guild.clean_history_duration (Union[
int
,datetime.timedelta
]) –The timespan (seconds or timedelta) of messages to delete from the user in the guild, up to 7 days (604800 seconds). Defaults to 1 day (86400 seconds).
This is incompatible with
delete_message_days
.New in version 2.6.
Note
This may not be accurate with small durations (e.g. a few minutes) and delete a couple minutes’ worth of messages more than specified.
delete_message_days (
int
) –The number of days worth of messages to delete from the user in the guild. The minimum is 0 and the maximum is 7.
This is incompatible with
clean_history_duration
.Deprecated since version 2.6: Use
clean_history_duration
instead.reason (Optional[
str
]) – The reason for banning this user. Shows up on the audit log.
- Raises:
TypeError – Both
clean_history_duration
anddelete_message_days
were provided, orclean_history_duration
has an invalid type.Forbidden – You do not have the proper permissions to ban.
HTTPException – Banning failed.
- await unban(user, *, reason=None)[source]¶
This function is a coroutine.
Unbans a user from the guild.
The user must meet the
abc.Snowflake
abc.You must have
ban_members
permission to do this.- Parameters:
user (
abc.Snowflake
) – The user to unban.reason (Optional[
str
]) – The reason for unbanning this user. Shows up on the audit log.
- Raises:
Forbidden – You do not have the proper permissions to unban.
HTTPException – Unbanning failed.
- await bulk_ban(users, *, clean_history_duration=0, reason=None)[source]¶
This function is a coroutine.
Bans multiple users from the guild at once.
The users must meet the
abc.Snowflake
abc.You must have
ban_members
andmanage_guild
permissions to do this.New in version 2.10.
- Parameters:
users (Iterable[
abc.Snowflake
]) – The users to ban from the guild, up to 200.clean_history_duration (Union[
int
,datetime.timedelta
]) –The timespan (seconds or timedelta) of messages to delete from the users in the guild, up to 7 days (604800 seconds). Defaults to
0
.Note
This may not be accurate with small durations (e.g. a few minutes) and delete a couple minutes’ worth of messages more than specified.
reason (Optional[
str
]) – The reason for banning the users. Shows up on the audit log.
- Raises:
TypeError –
clean_history_duration
has an invalid type.Forbidden – You do not have the proper permissions to bulk ban.
HTTPException – Banning failed. This is also raised if none of the users could be banned.
- Returns:
An object containing the successful and failed bans.
- Return type:
- await vanity_invite(*, use_cached=False)[source]¶
This function is a coroutine.
Returns the guild’s special vanity invite.
The guild must have
VANITY_URL
infeatures
.If
use_cached
is False, then you must havemanage_guild
permission to use this.- Parameters:
use_cached (
bool
) –Whether to use the cached
Guild.vanity_url_code
and attempt to convert it into a full invite.Note
If set to
True
, theInvite.uses
information will not be accurate.New in version 2.5.
- Raises:
Forbidden – You do not have the proper permissions to get this.
HTTPException – Retrieving the vanity invite failed.
- Returns:
The special vanity invite. If
None
then the guild does not have a vanity invite set.- Return type:
Optional[
Invite
]
- await widget()[source]¶
This function is a coroutine.
Retrieves the widget of the guild.
Note
The guild must have the widget enabled to get this information.
- Raises:
Forbidden – The widget for this guild is disabled.
HTTPException – Retrieving the widget failed.
- Returns:
The guild’s widget.
- Return type:
- await widget_settings()[source]¶
This function is a coroutine.
Retrieves the widget settings of the guild.
To edit the widget settings, you may also use
edit_widget()
.New in version 2.5.
- Raises:
Forbidden – You do not have permission to view the widget settings.
HTTPException – Retrieving the widget settings failed.
- Returns:
The guild’s widget settings.
- Return type:
- await edit_widget(*, enabled=..., channel=..., reason=None)[source]¶
This function is a coroutine.
Edits the widget of the guild.
You must have
manage_guild
permission to use this.New in version 2.0.
Changed in version 2.5: Returns the new widget settings.
- Parameters:
enabled (
bool
) – Whether to enable the widget for the guild.channel (Optional[
Snowflake
]) – The new widget channel.None
removes the widget channel. If set, an invite link for this channel will be generated, which allows users to join the guild from the widget.reason (Optional[
str
]) –The reason for editing the widget. Shows up on the audit log.
New in version 2.4.
- Raises:
Forbidden – You do not have permission to edit the widget.
HTTPException – Editing the widget failed.
- Returns:
The new widget settings.
- Return type:
- widget_image_url(style=<WidgetStyle.shield: 'shield'>)[source]¶
Returns an URL to the widget’s .png image.
New in version 2.5.
- Parameters:
style (
WidgetStyle
) – The widget style.- Returns:
The widget image URL.
- Return type:
- await edit_mfa_level(mfa_level, *, reason=None)[source]¶
This function is a coroutine.
Edits the two-factor authentication level of the guild.
You must be the guild owner to use this.
New in version 2.6.
- Parameters:
- Raises:
HTTPException – Editing the 2FA level failed.
ValueError – You are not the owner of the guild.
- await chunk(*, cache=True)[source]¶
This function is a coroutine.
Returns a
list
of all guild members.Requests all members that belong to this guild. In order to use this,
Intents.members()
must be enabled.This is a websocket operation and can be slow.
New in version 1.5.
- Parameters:
cache (
bool
) – Whether to cache the members as well.- Raises:
ClientException – The members intent is not enabled.
- Returns:
Returns a list of all the members within the guild.
- Return type:
Optional[List[
Member
]]
- await query_members(query=None, *, limit=5, user_ids=None, presences=False, cache=True)[source]¶
This function is a coroutine.
Request members that belong to this guild whose name starts with the query given.
This is a websocket operation and can be slow.
See also
search_members()
.New in version 1.3.
- Parameters:
query (Optional[
str
]) – The string that the names start with.limit (
int
) – The maximum number of members to send back. This must be a number between 5 and 100.presences (
bool
) –Whether to request for presences to be provided. This defaults to
False
.New in version 1.6.
cache (
bool
) – Whether to cache the members internally. This makes operations such asget_member()
work for those that matched.user_ids (Optional[List[
int
]]) –List of user IDs to search for. If the user ID is not in the guild then it won’t be returned.
New in version 1.4.
- Raises:
asyncio.TimeoutError – The query timed out waiting for the members.
ValueError – Invalid parameters were passed to the function
ClientException – The presences intent is not enabled.
- Returns:
The list of members that have matched the query.
- Return type:
List[
Member
]
- await search_members(query, *, limit=1, cache=True)[source]¶
This function is a coroutine.
Retrieves members that belong to this guild whose name starts with the query given.
Note that unlike
query_members()
, this is not a websocket operation, but an HTTP operation.See also
query_members()
.New in version 2.5.
- Parameters:
query (
str
) – The string that the names start with.limit (
int
) – The maximum number of members to send back. This must be a number between 1 and 1000.cache (
bool
) – Whether to cache the members internally. This makes operations such asget_member()
work for those that matched.
- Raises:
ValueError – Invalid parameters were passed to the function
- Returns:
The list of members that have matched the query.
- Return type:
List[
Member
]
- await get_or_fetch_members(user_ids, *, presences=False, cache=True)[source]¶
This function is a coroutine.
Tries to get the guild members matching the provided IDs from cache. If some of them were not found, the method requests the missing members using websocket operations. If
cache
kwarg isTrue
(default value) the missing members will be cached.If more than 100 members are missing, several websocket operations are made.
Websocket operations can be slow, however, this method is cheaper than multiple
get_or_fetch_member()
calls.New in version 2.4.
- Parameters:
user_ids (List[
int
]) – List of user IDs to search for. If the user ID is not in the guild then it won’t be returned.presences (
bool
) – Whether to request for presences to be provided. Defaults toFalse
.cache (
bool
) – Whether to cache the missing members internally. This makes operations such asget_member()
work for those that matched. It also speeds up this method on repeated calls. Defaults toTrue
.
- Raises:
asyncio.TimeoutError – The query timed out waiting for the members.
ClientException – The presences intent is not enabled.
- Returns:
The list of members with the given IDs, if they exist.
- Return type:
List[
Member
]
- await getch_members(user_ids, *, presences=False, cache=True)[source]¶
This function is a coroutine.
Tries to get the guild members matching the provided IDs from cache. If some of them were not found, the method requests the missing members using websocket operations. If
cache
kwarg isTrue
(default value) the missing members will be cached.If more than 100 members are missing, several websocket operations are made.
Websocket operations can be slow, however, this method is cheaper than multiple
get_or_fetch_member()
calls.New in version 2.4.
- Parameters:
user_ids (List[
int
]) – List of user IDs to search for. If the user ID is not in the guild then it won’t be returned.presences (
bool
) – Whether to request for presences to be provided. Defaults toFalse
.cache (
bool
) – Whether to cache the missing members internally. This makes operations such asget_member()
work for those that matched. It also speeds up this method on repeated calls. Defaults toTrue
.
- Raises:
asyncio.TimeoutError – The query timed out waiting for the members.
ClientException – The presences intent is not enabled.
- Returns:
The list of members with the given IDs, if they exist.
- Return type:
List[
Member
]
- await fetch_voice_regions()[source]¶
This function is a coroutine.
Retrieves a list of
VoiceRegion
for this guild.New in version 2.5.
- Raises:
HTTPException – Retrieving voice regions failed.
- await fetch_voice_state(member_id, /)[source]¶
This function is a coroutine.
Fetches the
VoiceState
of a member.Note
This method is an API call. For general usage, consider
Member.voice
instead.New in version 2.10.
- Parameters:
member_id (
int
) – The ID of the member.- Raises:
NotFound – The member for which you tried to fetch a voice state is not connected to a channel in this guild.
Forbidden – You do not have permission to fetch the member’s voice state.
HTTPException – Fetching the voice state failed.
- Returns:
The voice state of the member.
- Return type:
- await change_voice_state(*, channel, self_mute=False, self_deaf=False)[source]¶
This function is a coroutine.
Changes client’s voice state in the guild.
New in version 1.4.
- Parameters:
channel (Optional[
VoiceChannel
]) – The channel the client wants to join. UseNone
to disconnect.self_mute (
bool
) – Whether the client should be self-muted.self_deaf (
bool
) – Whether the client should be self-deafened.
- await bulk_fetch_command_permissions()[source]¶
This function is a coroutine.
Requests a list of
GuildApplicationCommandPermissions
configured for this guild.New in version 2.1.
- await fetch_command_permissions(command_id)[source]¶
This function is a coroutine.
Retrieves
GuildApplicationCommandPermissions
for a specific command.New in version 2.1.
- Parameters:
command_id (
int
) –The ID of the application command, or the application ID to fetch application-wide permissions.
Changed in version 2.5: Can now also fetch application-wide permissions.
- Returns:
The application command permissions.
- Return type:
- await timeout(user, *, duration=..., until=..., reason=None)[source]¶
This function is a coroutine.
Times out the member from the guild; until then, the member will not be able to interact with the guild.
Exactly one of
duration
oruntil
must be provided. To remove a timeout, set one of the parameters toNone
.The user must meet the
abc.Snowflake
abc.You must have the
moderate_members
permission to do this.New in version 2.3.
- Parameters:
user (
abc.Snowflake
) – The member to timeout.duration (Optional[Union[
float
,datetime.timedelta
]]) – The duration (seconds or timedelta) of the member’s timeout. Set toNone
to remove the timeout. Supports up to 28 days in the future. May not be used in combination with theuntil
parameter.until (Optional[
datetime.datetime
]) – The expiry date/time of the member’s timeout. Set toNone
to remove the timeout. Supports up to 28 days in the future. May not be used in combination with theduration
parameter.reason (Optional[
str
]) – The reason for this timeout. Shows up on the audit log.
- Raises:
Forbidden – You do not have permissions to timeout this member.
HTTPException – Timing out the member failed.
- Returns:
The newly updated member.
- Return type:
- await fetch_automod_rule(rule_id, /)[source]¶
This function is a coroutine.
Retrieves an auto moderation rules from the guild. See also
fetch_automod_rules()
.Requires the
manage_guild
permission.New in version 2.6.
- Raises:
Forbidden – You do not have proper permissions to retrieve auto moderation rules.
NotFound – An auto moderation rule with the provided ID does not exist in the guild.
HTTPException – Retrieving the rule failed.
- Returns:
The auto moderation rule.
- Return type:
- await fetch_automod_rules()[source]¶
This function is a coroutine.
Retrieves the guild’s auto moderation rules. See also
fetch_automod_rule()
.Requires the
manage_guild
permission.New in version 2.6.
- Raises:
Forbidden – You do not have proper permissions to retrieve auto moderation rules.
NotFound – The guild does not have any auto moderation rules set up.
HTTPException – Retrieving the rules failed.
- Returns:
The guild’s auto moderation rules.
- Return type:
List[
AutoModRule
]
- await create_automod_rule(*, name, event_type, trigger_type, actions, trigger_metadata=None, enabled=False, exempt_roles=None, exempt_channels=None, reason=None)[source]¶
This function is a coroutine.
Creates a new
AutoModRule
for the guild.You must have
Permissions.manage_guild
permission to do this.The maximum number of rules for each trigger type is limited, see the api docs for more details.
New in version 2.6.
Changed in version 2.9: Now raises a
TypeError
if givenactions
have an invalid type.- Parameters:
name (
str
) – The rule name.event_type (
AutoModEventType
) – The type of events that this rule will be applied to.trigger_type (
AutoModTriggerType
) – The type of trigger that determines whether this rule’s actions should run for a specific event. If set tokeyword
,keyword_preset
, ormention_spam
,trigger_metadata
must be set accordingly. This cannot be changed after creation.actions (Sequence[Union[
AutoModBlockMessageAction
,AutoModSendAlertAction
,AutoModTimeoutAction
,AutoModAction
]]) – The list of actions that will execute if a matching event triggered this rule. Must contain at least one action.trigger_metadata (Optional[
AutoModTriggerMetadata
]) – Additional metadata associated with the trigger type.enabled (
bool
) – Whether to enable the rule. Defaults toFalse
.exempt_roles (Optional[Sequence[
abc.Snowflake
]]) – The roles that are exempt from this rule, up to 20. By default, no roles are exempt.exempt_channels (Optional[Sequence[
abc.Snowflake
]]) – The channels that are exempt from this rule, up to 50. By default, no channels are exempt. Can also include categories, in which case all channels inside that category will be exempt.reason (Optional[
str
]) – The reason for creating the rule. Shows up on the audit log.
- Raises:
ValueError – The specified trigger type requires
trigger_metadata
to be set, or no actions have been provided.TypeError – The specified
actions
are of an invalid type.Forbidden – You do not have proper permissions to create auto moderation rules.
HTTPException – Creating the rule failed.
- Returns:
The newly created auto moderation rule.
- Return type:
- await onboarding()[source]¶
This function is a coroutine.
Retrieves the guild onboarding data.
New in version 2.9.
- Raises:
HTTPException – Retrieving the guild onboarding data failed.
- Returns:
The guild onboarding data.
- Return type:
GuildPreview¶
- class disnake.GuildPreview[source]¶
Represents a
Guild
preview object.New in version 2.5.
- stickers¶
All stickers that the guild owns.
- Type:
Tuple[
GuildSticker
, …]
- features¶
A list of features that the guild has. The features that a guild can have are subject to arbitrary change by Discord.
See
Guild.features
for a list of features.- Type:
List[
str
]
- approximate_presence_count¶
The approximate number of members currently active in the guild. This includes idle, dnd, online, and invisible members. Offline members are excluded.
- Type:
Template¶
- asynccreate_guild
- asyncdelete
- asyncedit
- asyncsync
- class disnake.Template[source]¶
Represents a Discord template.
New in version 1.4.
- created_at¶
An aware datetime in UTC representing when the template was created.
- Type:
- updated_at¶
An aware datetime in UTC representing when the template was last updated. This is referred to as “last synced” in the official Discord client.
- Type:
- await create_guild(name, icon=None)[source]¶
This function is a coroutine.
Creates a
Guild
using the template.Bot accounts in more than 10 guilds are not allowed to create guilds.
Changed in version 2.5: Removed the
region
parameter.Changed in version 2.6: Raises
ValueError
instead ofInvalidArgument
.- Parameters:
name (
str
) – The name of the guild.icon (Optional[Union[
bytes
,Asset
,Emoji
,PartialEmoji
,StickerItem
,Sticker
]]) –The icon of the guild. See
ClientUser.edit()
for more details on what is expected.Changed in version 2.5: Now accepts various resource types in addition to
bytes
.
- Raises:
NotFound – The
icon
asset couldn’t be found.HTTPException – Guild creation failed.
TypeError – The
icon
asset is a lottie sticker (seeSticker.read()
).ValueError – Invalid icon image format given. Must be PNG or JPG.
- Returns:
The guild created. This is not the same guild that is added to cache.
- Return type:
- await sync()[source]¶
This function is a coroutine.
Syncs the template to the guild’s current state.
You must have the
manage_guild
permission in the source guild to do this.New in version 1.7.
Changed in version 2.0: The template is no longer edited in-place, instead it is returned.
- Raises:
HTTPException – Editing the template failed.
Forbidden – You don’t have permissions to edit the template.
NotFound – This template does not exist.
- Returns:
The newly edited template.
- Return type:
- await edit(*, name=..., description=...)[source]¶
This function is a coroutine.
Edits the template metadata.
You must have the
manage_guild
permission in the source guild to do this.New in version 1.7.
Changed in version 2.0: The template is no longer edited in-place, instead it is returned.
- Parameters:
- Raises:
HTTPException – Editing the template failed.
Forbidden – You don’t have permissions to edit the template.
NotFound – This template does not exist.
- Returns:
The newly edited template.
- Return type:
- await delete()[source]¶
This function is a coroutine.
Deletes the template.
You must have the
manage_guild
permission in the source guild to do this.New in version 1.7.
- Raises:
HTTPException – Editing the template failed.
Forbidden – You don’t have permissions to edit the template.
NotFound – This template does not exist.
WelcomeScreen¶
- asyncedit
- class disnake.WelcomeScreen[source]¶
Represents a Discord welcome screen for a
Guild
.New in version 2.5.
- channels¶
The welcome screen’s channels.
- Type:
List[
WelcomeScreenChannel
]
- property enabled[source]¶
Whether the welcome screen is displayed to users. This is equivalent to checking if
WELCOME_SCREEN_ENABLED
is present inGuild.features
.- Type:
- await edit(*, enabled=..., description=..., channels=..., reason=None)[source]¶
This function is a coroutine.
Edits the welcome screen.
You must have the
manage_guild
permission to use this.This requires ‘COMMUNITY’ in
Guild.features
.- Parameters:
enabled (
bool
) – Whether the welcome screen is enabled.description (Optional[
str
]) – The new guild description in the welcome screen.channels (Optional[List[
WelcomeScreenChannel
]]) – The new welcome channels.reason (Optional[
str
]) – The reason for editing the welcome screen. Shows up on the audit log.
- Raises:
Forbidden – You do not have permissions to change the welcome screen or the guild is not allowed to create welcome screens.
HTTPException – Editing the welcome screen failed.
TypeError –
channels
is not a list ofWelcomeScreenChannel
instances
- Returns:
The newly edited welcome screen.
- Return type:
BanEntry¶
BulkBanResult¶
- class disnake.BulkBanResult¶
A
NamedTuple
which represents the successful and failed bans returned frombulk_ban()
.New in version 2.10.
Onboarding¶
- class disnake.Onboarding[source]¶
Represents a guild onboarding object.
New in version 2.9.
- prompts¶
The prompts shown during onboarding and in community customization.
- Type:
List[
OnboardingPrompt
]
- default_channel_ids¶
The IDs of the channels that will be shown to new members by default.
- Type:
FrozenSet[
int
]
- property default_channels[source]¶
The list of channels that will be shown to new members by default.
- Type:
List[
abc.GuildChannel
]
OnboardingPrompt¶
- class disnake.OnboardingPrompt[source]¶
Represents an onboarding prompt.
New in version 2.9.
- type¶
The onboarding prompt’s type.
- Type:
- options¶
The onboarding prompt’s options.
- Type:
List[
OnboardingPromptOption
]
OnboardingPromptOption¶
- class disnake.OnboardingPromptOption[source]¶
Represents an onboarding prompt option.
New in version 2.9.
- emoji¶
The prompt option’s emoji.
- Type:
Optional[Union[
PartialEmoji
,Emoji
,str
]]
- role_ids¶
The IDs of the roles that will be added to the user when they select this option.
- Type:
FrozenSet[
int
]
- channel_ids¶
The IDs of the channels that the user will see when they select this option.
- Type:
FrozenSet[
int
]
- property roles[source]¶
A list of roles that will be added to the user when they select this option.
- Type:
List[
Role
]
- property channels[source]¶
A list of channels that the user will see when they select this option.
- Type:
List[
abc.GuildChannel
]
Data Classes¶
SystemChannelFlags¶
- class disnake.SystemChannelFlags[source]¶
Wraps up a Discord system channel flag value.
Similar to
Permissions
, the properties provided are two way. You can set and retrieve individual bits using the properties as if they were regular bools. This allows you to edit the system flags easily.To construct an object you can pass keyword arguments denoting the flags to enable or disable. Arguments are applied in order, similar to
Permissions
.- x == y
Checks if two SystemChannelFlags instances are equal.
- x != y
Checks if two SystemChannelFlags instances are not equal.
- x <= y
Checks if a SystemChannelFlags instance is a subset of another SystemChannelFlags instance.
New in version 2.6.
- x >= y
Checks if a SystemChannelFlags instance is a superset of another SystemChannelFlags instance.
New in version 2.6.
- x < y
Checks if a SystemChannelFlags instance is a strict subset of another SystemChannelFlags instance.
New in version 2.6.
- x > y
Checks if a SystemChannelFlags instance is a strict superset of another SystemChannelFlags instance.
New in version 2.6.
- x | y, x |= y
Returns a new SystemChannelFlags instance with all enabled flags from both x and y. (Using
|=
will update in place).New in version 2.6.
- x & y, x &= y
Returns a new SystemChannelFlags instance with only flags enabled on both x and y. (Using
&=
will update in place).New in version 2.6.
- x ^ y, x ^= y
Returns a new SystemChannelFlags instance with only flags enabled on one of x or y, but not both. (Using
^=
will update in place).New in version 2.6.
- ~x
Returns a new SystemChannelFlags instance with all flags from x inverted.
New in version 2.6.
- hash(x)
Return the flag’s hash.
- iter(x)
Returns an iterator of
(name, value)
pairs. This allows it to be, for example, constructed as a dict or a list of pairs.
Additionally supported are a few operations on class attributes.
- SystemChannelFlags.y | SystemChannelFlags.z, SystemChannelFlags(y=True) | SystemChannelFlags.z
Returns a SystemChannelFlags instance with all provided flags enabled.
- ~SystemChannelFlags.y
Returns a SystemChannelFlags instance with all flags except
y
inverted from their default value.
- value¶
The raw value. This value is a bit array field of a 53-bit integer representing the currently available flags. You should query flags via the properties rather than using this raw value.
- Type:
- join_notifications¶
Returns
True
if the system channel is used for member join notifications.- Type:
Returns
True
if the system channel is used for “Nitro boosting” notifications.- Type:
- guild_reminder_notifications¶
Returns
True
if the system channel is used for server setup helpful tips notifications.New in version 2.0.
- Type:
- join_notification_replies¶
Returns
True
if the system channel shows sticker reply buttons for member join notifications.New in version 2.3.
- Type:
- role_subscription_purchase_notifications¶
Returns
True
if the system channel shows role subscription purchase/renewal notifications.New in version 2.9.
- Type:
WelcomeScreenChannel¶
- class disnake.WelcomeScreenChannel[source]¶
Represents a Discord welcome screen channel.
New in version 2.5.
- emoji¶
The emoji associated with this channel’s welcome message, if any.
- Type:
Optional[Union[
Emoji
,PartialEmoji
]]
GuildBuilder¶
- defadd_category
- defadd_role
- defadd_text_channel
- defadd_voice_channel
- asynccreate
- defupdate_everyone_role
- class disnake.GuildBuilder[source]¶
A guild builder object, created by
Client.guild_builder()
.This allows for easier configuration of more complex guild setups, abstracting away some of the quirks of the guild creation endpoint.
New in version 2.8.
Note
Many methods of this class return unspecified placeholder IDs (called
PlaceholderID
below) that can be used to reference the created object in other objects, for example referencing a category when creating a new text channel, or a role when setting permission overwrites.Examples
Basic usage:
builder = client.guild_builder("Cat Pics") builder.add_text_channel("meow", topic="cat.") guild = await builder.create()
Adding more channels + roles:
builder = client.guild_builder("More Cat Pics") builder.add_text_channel("welcome") # add roles guests = builder.add_role("guests") admins = builder.add_role( "catmins", permissions=Permissions(administrator=True), hoist=True, ) # add cat-egory and text channel category = builder.add_category("cats!") meow_channel = builder.add_text_channel( "meow", topic="cat.", category=category, overwrites={guests: PermissionOverwrite(send_messages=False)} ) # set as system channel builder.system_channel = meow_channel # add hidden voice channel builder.add_voice_channel( "secret-admin-vc", category=category, overwrites={builder.everyone: PermissionOverwrite(view_channel=False)} ) # finally, create the guild guild = await builder.create()
- icon¶
The icon of the new guild.
- Type:
Optional[Union[
bytes
,Asset
,Emoji
,PartialEmoji
,StickerItem
,Sticker
]]
- verification_level¶
The verification level of the new guild.
- Type:
Optional[
VerificationLevel
]
- default_notifications¶
The default notification level for the new guild.
- Type:
Optional[
NotificationLevel
]
- explicit_content_filter¶
The explicit content filter for the new guild.
- Type:
Optional[
ContentFilter
]
- afk_channel¶
The channel that is used as the AFK channel.
- Type:
Optional[
PlaceholderID
]
- system_channel¶
The channel that is used as the system channel.
- Type:
Optional[
PlaceholderID
]
- system_channel_flags¶
The settings to use with the system channel.
- Type:
Optional[
SystemChannelFlags
]
- await create()[source]¶
This function is a coroutine.
Creates the configured guild.
- Raises:
HTTPException – Guild creation failed.
ValueError – Invalid icon image format given. Must be PNG or JPG.
TypeError – The
icon
asset is a lottie sticker (seeSticker.read
).
- Returns:
The created guild. This is not the same guild that is added to cache.
Note
Due to API limitations, this returned guild does not contain any of the configured channels.
- Return type:
- update_everyone_role(*, permissions=...)[source]¶
Updates attributes of the
@everyone
role.- Parameters:
permissions (
Permissions
) – The permissions the role should have.- Returns:
The placeholder ID for the
@everyone
role. Also available aseveryone
.- Return type:
PlaceholderID
- add_role(name=..., *, permissions=..., color=..., colour=..., hoist=..., mentionable=...)[source]¶
Adds a role to the guild builder.
The default (
@everyone
) role can be referenced usingeveryone
and configured throughupdate_everyone_role()
.- Parameters:
name (
str
) – The role name. Defaults to ‘new role’.permissions (
Permissions
) – The permissions the role should have. Defaults to no permissions.colour (Union[
Colour
,int
]) – The colour for the role. Defaults toColour.default()
. This is aliased tocolor
as well.hoist (
bool
) – Whether the role should be shown separately in the member list. Defaults toFalse
.mentionable (
bool
) – Whether the role should be mentionable by others. Defaults toFalse
.
- Returns:
A placeholder ID for the created role.
- Return type:
PlaceholderID
- add_category(name, *, overwrites=...)[source]¶
Adds a category channel to the guild builder.
There is an alias for this named
add_category_channel
.- Parameters:
name (
str
) – The category’s name.overwrites (Dict[
PlaceholderID
,PermissionOverwrite
]) – Adict
of roles toPermissionOverwrite
s which can be synced to channels.
- Returns:
A placeholder ID for the created category.
- Return type:
PlaceholderID
- add_text_channel(name, *, overwrites=..., category=..., topic=..., slowmode_delay=..., nsfw=..., default_auto_archive_duration=...)[source]¶
Adds a text channel to the guild builder.
- Parameters:
name (
str
) – The channel’s name.overwrites (Dict[
PlaceholderID
,PermissionOverwrite
]) – Adict
of roles toPermissionOverwrite
s to apply to the channel.category (
PlaceholderID
) –The category to place the new channel under.
Warning
Unlike
Guild.create_text_channel()
, the parent category’s permissions will not be synced to this new channel by default.topic (Optional[
str
]) – The channel’s topic.slowmode_delay (
int
) – Specifies the slowmode rate limit for users in this channel, in seconds. A value of0
disables slowmode. The maximum value possible is21600
. If not provided, slowmode is disabled.nsfw (
bool
) – Whether to mark the channel as NSFW.default_auto_archive_duration (Union[
int
,ThreadArchiveDuration
]) – The default auto archive duration in minutes for threads created in this channel. Must be one of60
,1440
,4320
, or10080
.
- Returns:
A placeholder ID for the created text channel.
- Return type:
PlaceholderID
- add_voice_channel(name, *, overwrites=..., category=..., slowmode_delay=..., nsfw=..., bitrate=..., user_limit=..., rtc_region=..., video_quality_mode=...)[source]¶
Adds a voice channel to the guild builder.
- Parameters:
name (
str
) – The channel’s name.overwrites (Dict[
PlaceholderID
,PermissionOverwrite
]) – Adict
of roles toPermissionOverwrite
s to apply to the channel.category (
PlaceholderID
) –The category to place the new channel under.
Warning
Unlike
Guild.create_voice_channel()
, the parent category’s permissions will not be synced to this new channel by default.slowmode_delay (
int
) – Specifies the slowmode rate limit for users in this channel, in seconds. A value of0
disables slowmode. The maximum value possible is21600
. If not provided, slowmode is disabled.nsfw (
bool
) – Whether to mark the channel as NSFW.bitrate (
int
) – The channel’s preferred audio bitrate in bits per second.user_limit (
int
) – The channel’s limit for number of members that can be in a voice channel.rtc_region (Optional[Union[
str
,VoiceRegion
]]) – The region for the voice channel’s voice communication. A value ofNone
indicates automatic voice region detection.video_quality_mode (
VideoQualityMode
) – The camera video quality for the voice channel’s participants.
- Returns:
A placeholder ID for the created voice channel.
- Return type:
PlaceholderID
Enumerations¶
VerificationLevel¶
- class disnake.VerificationLevel[source]¶
Specifies a
Guild
's verification level, which is the criteria in which a member must meet before being able to send messages to the guild.New in version 2.0.
- x == y
Checks if two verification levels are equal.
- x != y
Checks if two verification levels are not equal.
- x > y
Checks if a verification level is higher than another.
- x < y
Checks if a verification level is lower than another.
- x >= y
Checks if a verification level is higher or equal to another.
- x <= y
Checks if a verification level is lower or equal to another.
- none¶
No criteria set.
- low¶
Member must have a verified email on their Discord account.
- medium¶
Member must have a verified email and be registered on Discord for more than five minutes.
- high¶
Member must have a verified email, be registered on Discord for more than five minutes, and be a member of the guild itself for more than ten minutes.
- highest¶
Member must have a verified phone on their Discord account.
NotificationLevel¶
- class disnake.NotificationLevel[source]¶
Specifies whether a
Guild
has notifications on for all messages or mentions only by default.- x == y
Checks if two notification levels are equal.
- x != y
Checks if two notification levels are not equal.
- x > y
Checks if a notification level is higher than another.
- x < y
Checks if a notification level is lower than another.
- x >= y
Checks if a notification level is higher or equal to another.
- x <= y
Checks if a notification level is lower or equal to another.
- all_messages¶
Members receive notifications for every message regardless of them being mentioned.
- only_mentions¶
Members receive notifications for messages they are mentioned in.
ContentFilter¶
- class disnake.ContentFilter[source]¶
Specifies a
Guild
's explicit content filter, which is the machine learning algorithms that Discord uses to detect if an image contains NSFW content.- x == y
Checks if two content filter levels are equal.
- x != y
Checks if two content filter levels are not equal.
- x > y
Checks if a content filter level is higher than another.
- x < y
Checks if a content filter level is lower than another.
- x >= y
Checks if a content filter level is higher or equal to another.
- x <= y
Checks if a content filter level is lower or equal to another.
- disabled¶
The guild does not have the content filter enabled.
- no_role¶
The guild has the content filter enabled for members without a role.
- all_members¶
The guild has the content filter enabled for every member.
NSFWLevel¶
- class disnake.NSFWLevel[source]¶
Represents the NSFW level of a guild.
New in version 2.0.
- x == y
Checks if two NSFW levels are equal.
- x != y
Checks if two NSFW levels are not equal.
- x > y
Checks if a NSFW level is higher than another.
- x < y
Checks if a NSFW level is lower than another.
- x >= y
Checks if a NSFW level is higher or equal to another.
- x <= y
Checks if a NSFW level is lower or equal to another.
- default¶
The guild has not been categorised yet.
- explicit¶
The guild contains NSFW content.
- safe¶
The guild does not contain any NSFW content.
- age_restricted¶
The guild may contain NSFW content.