Guild¶
discord_http.guild module¶
- class discord_http.guild.Guild(*, state: DiscordAPI, data: dict)[source]¶
Bases:
PartialGuild
- property bitrate_limit: int¶
The maximum bitrate the guild can have
- Type:
float
- property emojis_limit: int¶
The maximum amount of emojis the guild can have
- Type:
int
- property filesize_limit: int¶
The maximum filesize the guild can have
- Type:
int
- get_member_top_role(member: Member) Role | None [source]¶
Get the top role of a member, because Discord API does not order roles
- Parameters:
member (Member) – The member to get the top role of
- Returns:
The top role of the member
- Return type:
Optional[Role]
- get_role(role_id: int) Role | None [source]¶
Get a role from the guild
This simply returns the role from the role list in this object if it exists
- Parameters:
role_id (int) – The ID of the role to get
- Returns:
The role if it exists, else None
- Return type:
Optional[Role]
- get_role_by_name(role_name: str) Role | None [source]¶
Gets the first role with the specified name
- Parameters:
role_name (str) – The name of the role to get (case sensitive)
- Returns:
The role if it exists, else None
- Return type:
Optional[Role]
The guild’s premium subscriber role if available
- Type:
Optional[Role]
- property stickers_limit: int¶
The maximum amount of stickers the guild can have
- Type:
int
- class discord_http.guild.PartialGuild(*, state: DiscordAPI, id: int)[source]¶
Bases:
PartialBase
- async ban(member: Member | PartialMember | int, *, reason: str | None = None, delete_message_days: int | None = 0, delete_message_seconds: int | None = 0) None [source]¶
Ban a member from the server
- Parameters:
member (Union[Member, PartialMember, int]) – The member to ban
reason (Optional[str]) – The reason for banning the member
delete_message_days (Optional[int]) – How many days of messages to delete
delete_message_seconds (Optional[int]) – How many seconds of messages to delete
- async begin_guild_prune(*, days: int | None = 7, compute_prune_count: bool = True, include_roles: list[Role | PartialRole | int] | None = None, reason: str | None = None) int | None [source]¶
Begin a guild prune
- Parameters:
days (Optional[int]) – How many days of inactivity to prune for
compute_prune_count (bool) – Whether to return the amount of members that would be pruned
include_roles (Optional[list[Union[Role, PartialRole, int]]]) – Which roles to include in the prune
reason (Optional[str]) – The reason for beginning the prune
- Returns:
The amount of members that were pruned
- Return type:
Optional[int]
- async create_category(name: str, *, overwrites: list[PermissionOverwrite] | None = None, position: int | None = None, reason: str | None = None) CategoryChannel [source]¶
Create a category channel
- Parameters:
name (str) – The name of the category
overwrites (Optional[list[PermissionOverwrite]]) – The permission overwrites of the category
position (Optional[int]) – The position of the category
reason (Optional[str]) – The reason for creating the category
- Returns:
The created category
- Return type:
CategoryChannel
- async create_emoji(name: str, *, image: File | bytes, reason: str | None = None) Emoji [source]¶
Create an emoji
- Parameters:
name (str) – Name of the emoji
image (File) – File object to create an emoji from
reason (Optional[str]) – The reason for creating the emoji
- Returns:
The created emoji
- Return type:
Emoji
- async create_guild(name: str, *, icon: File | bytes | None = None, reason: str | None = None) Guild [source]¶
Create a guild
Note that the bot must be in less than 10 guilds to use this endpoint
- Parameters:
name (str) – The name of the guild
icon (Optional[File]) – The icon of the guild
reason (Optional[str]) – The reason for creating the guild
- Returns:
The created guild
- Return type:
Guild
- async create_role(name: str, *, permissions: Permissions | None = None, color: Colour | Color | int | None = None, colour: Colour | Color | int | None = None, unicode_emoji: str | None = None, icon: File | bytes | None = None, hoist: bool = False, mentionable: bool = False, reason: str | None = None) Role [source]¶
Create a role
- Parameters:
name (str) – The name of the role
permissions (Optional[Permissions]) – The permissions of the role
color (Optional[Union[Colour, Color, int]]) – The colour of the role
colour (Optional[Union[Colour, Color, int]]) – The colour of the role
hoist (bool) – Whether the role should be hoisted
mentionable (bool) – Whether the role should be mentionable
unicode_emoji (Optional[str]) – The unicode emoji of the role
icon (Optional[File]) – The icon of the role
reason (Optional[str]) – The reason for creating the role
- Returns:
The created role
- Return type:
Role
- async create_scheduled_event(name: str, *, start_time: datetime | timedelta | int, end_time: datetime | timedelta | int | None = None, channel: PartialChannel | int | None = None, description: str | None = None, privacy_level: ScheduledEventPrivacyType | None = None, entity_type: ScheduledEventEntityType | None = None, external_location: str | None = None, image: File | bytes | None = None, reason: str | None = None) ScheduledEvent [source]¶
Create a scheduled event
- Parameters:
name (str) – The name of the event
start_time (Union[datetime, timedelta, int]) – The start time of the event
end_time (Optional[Union[datetime, timedelta, int]]) – The end time of the event
channel (Optional[Union[PartialChannel, int]]) – The channel of the event
description (Optional[str]) – The description of the event
privacy_level (Optional[ScheduledEventPrivacyType]) – The privacy level of the event (default is guild_only)
entity_type (Optional[ScheduledEventEntityType]) – The entity type of the event (default is voice)
external_location (Optional[str]) – The external location of the event
image (Optional[Union[File, bytes]]) – The image of the event
reason (Optional[str]) – The reason for creating the event
- Returns:
The created event
- Return type:
ScheduledEvent
- async create_stage_channel(name: str, *, bitrate: int | None = None, user_limit: int | None = None, overwrites: list[PermissionOverwrite] | None = None, position: int | None = None, parent_id: Snowflake | int | None = None, video_quality_mode: VideoQualityType | int | None = None, reason: str | None = None) StageChannel [source]¶
Create a stage channel
- Parameters:
name (str) – The name of the channel
bitrate (Optional[int]) – The bitrate of the channel
user_limit (Optional[int]) – The user limit of the channel
overwrites (Optional[list[PermissionOverwrite]]) – The permission overwrites of the category
position (Optional[int]) – The position of the channel
video_quality_mode (Optional[Union[VideoQualityType, int]]) – The video quality mode of the channel
parent_id (Optional[Union[Snowflake, int]]) – The Category ID where the channel will be placed
reason (Optional[str]) – The reason for creating the stage channel
- Returns:
The created channel
- Return type:
StageChannel
- async create_sticker(name: str, *, description: str, emoji: str, file: File, reason: str | None = None) Sticker [source]¶
Create a sticker
- Parameters:
name (str) – Name of the sticker
description (str) – Description of the sticker
emoji (str) – Emoji that represents the sticker
file (File) – File object to create a sticker from
reason (Optional[str]) – The reason for creating the sticker
- Returns:
The created sticker
- Return type:
Sticker
- async create_text_channel(name: str, *, topic: str | None = None, position: int | None = None, rate_limit_per_user: int | None = None, overwrites: list[PermissionOverwrite] | None = None, parent_id: Snowflake | int | None = None, nsfw: bool | None = None, reason: str | None = None) TextChannel [source]¶
Create a text channel
- Parameters:
name (str) – The name of the channel
topic (Optional[str]) – The topic of the channel
rate_limit_per_user (Optional[int]) – The rate limit per user of the channel
overwrites (Optional[list[PermissionOverwrite]]) – The permission overwrites of the category
parent_id (Optional[Snowflake]) – The Category ID where the channel will be placed
nsfw (Optional[bool]) – Whether the channel is NSFW or not
reason (Optional[str]) – The reason for creating the text channel
- Returns:
The created channel
- Return type:
TextChannel
- async create_voice_channel(name: str, *, bitrate: int | None = None, user_limit: int | None = None, rate_limit_per_user: int | None = None, overwrites: list[PermissionOverwrite] | None = None, position: int | None = None, video_quality_mode: VideoQualityType | int | None = None, parent_id: Snowflake | int | None = None, nsfw: bool | None = None, reason: str | None = None) VoiceChannel [source]¶
Create a voice channel
- Parameters:
name (str) – The name of the channel
bitrate (Optional[int]) – The bitrate of the channel
user_limit (Optional[int]) – The user limit of the channel
rate_limit_per_user (Optional) – The rate limit per user of the channel
overwrites (Optional[list[PermissionOverwrite]]) – The permission overwrites of the category
position (Optional[int]) – The position of the channel
video_quality_mode (Optional[Union[VideoQualityType, int]]) – The video quality mode of the channel
parent_id (Optional[Snowflake]) – The Category ID where the channel will be placed
nsfw (Optional[bool]) – Whether the channel is NSFW or not
reason (Optional[str]) – The reason for creating the voice channel
- Returns:
The created channel
- Return type:
VoiceChannel
- property default_role: PartialRole¶
Returns the default role, but as a partial role object
- Type:
Role
- async edit(*, name: str | None = <MISSING>, verification_level: ~discord_http.enums.VerificationLevel | None = <MISSING>, default_message_notifications: ~discord_http.enums.DefaultNotificationLevel | None = <MISSING>, explicit_content_filter: ~discord_http.enums.ContentFilterLevel | None = <MISSING>, afk_channel_id: VoiceChannel | PartialChannel | int | None = <MISSING>, afk_timeout: int | None = <MISSING>, icon: ~discord_http.file.File | bytes | None = <MISSING>, owner_id: Member | PartialMember | int | None = <MISSING>, splash: ~discord_http.file.File | bytes | None = <MISSING>, discovery_splash: ~discord_http.file.File | None = <MISSING>, banner: ~discord_http.file.File | bytes | None = <MISSING>, system_channel_id: TextChannel | PartialChannel | int | None = <MISSING>, system_channel_flags: ~discord_http.flag.SystemChannelFlags | None = <MISSING>, rules_channel_id: TextChannel | PartialChannel | int | None = <MISSING>, public_updates_channel_id: TextChannel | PartialChannel | int | None = <MISSING>, preferred_locale: str | None = <MISSING>, description: str | None = <MISSING>, features: list[str] | None = <MISSING>, premium_progress_bar_enabled: bool | None = <MISSING>, safety_alerts_channel_id: TextChannel | PartialChannel | int | None = <MISSING>, reason: str | None = None) PartialGuild [source]¶
Edit the guild
- Parameters:
name (Optional[str]) – New name of the guild
verification_level (Optional[VerificationLevel]) – Verification level of the guild
default_message_notifications (Optional[DefaultNotificationLevel]) – Default message notification level of the guild
explicit_content_filter (Optional[ContentFilterLevel]) – Explicit content filter level of the guild
afk_channel_id (Optional[Union[VoiceChannel, PartialChannel, int]]) – AFK channel of the guild
afk_timeout (Optional[int]) – AFK timeout of the guild
icon (Optional[File]) – Icon of the guild
owner_id (Optional[Union[Member, PartialMember, int]]) – Owner of the guild
splash (Optional[File]) – Splash of the guild
discovery_splash (Optional[File]) – Discovery splash of the guild
banner (Optional[File]) – Banner of the guild
system_channel_id (Optional[Union[TextChannel, PartialChannel, int]]) – System channel of the guild
system_channel_flags (Optional[SystemChannelFlags]) – System channel flags of the guild
rules_channel_id (Optional[Union[TextChannel, PartialChannel, int]]) – Rules channel of the guild
public_updates_channel_id (Optional[Union[TextChannel, PartialChannel, int]]) – Public updates channel of the guild
preferred_locale (Optional[str]) – Preferred locale of the guild
description (Optional[str]) – Description of the guild
features (Optional[list[str]]) – Features of the guild
premium_progress_bar_enabled (Optional[bool]) – Whether the premium progress bar is enabled
safety_alerts_channel_id (Optional[Union[TextChannel, PartialChannel, int]]) – Safety alerts channel of the guild
reason (Optional[str]) – The reason for editing the guild
- Returns:
The edited guild
- Return type:
PartialGuild
- async fetch_channel(channel_id: int) BaseChannel [source]¶
Fetch a channel from the guild
- Parameters:
channel_id (int) – The ID of the channel
- Returns:
The channel object
- Return type:
BaseChannel
- async fetch_channels() list[type[BaseChannel]] [source]¶
list[BaseChannel]: Fetches all the channels in the guild
- async fetch_guild_prune_count(*, days: int | None = 7, include_roles: list[Role | PartialRole | int] | None = None) int [source]¶
Fetch the amount of members that would be pruned
- Parameters:
days (Optional[int]) – How many days of inactivity to prune for
include_roles (Optional[list[Union[Role, PartialRole, int]]]) – Which roles to include in the prune
- Returns:
The amount of members that would be pruned
- Return type:
int
- async fetch_member(member_id: int) Member [source]¶
Fetch a member from the guild
- Parameters:
member_id (int) – The ID of the member
- Returns:
The member object
- Return type:
Member
- async fetch_members(*, limit: int | None = 1000, after: Snowflake | int | None = None) AsyncIterator[Member] [source]¶
Fetches all the members in the guild
- Parameters:
limit (Optional[int]) – The maximum amount of members to return
after (Optional[Union[Snowflake, int]]) – The member to start after
- Yields:
Members – The members in the guild
- async fetch_public_threads() list[PublicThread] [source]¶
Fetches all the public threads in the guild
- Returns:
The public threads in the guild
- Return type:
list[PublicThread]
- async fetch_regions() list[VoiceRegion] [source]¶
list[VoiceRegion]: Fetches all the voice regions for the guild
- async fetch_scheduled_event(id: int) ScheduledEvent [source]¶
Fetches a scheduled event object.
- Parameters:
id (int) – The ID of the scheduled event.
- Returns:
The scheduled event object.
- Return type:
ScheduledEvent
- async fetch_scheduled_events_list() list[ScheduledEvent] [source]¶
list[ScheduledEvent]: Fetches all the scheduled events in the guild
- async fetch_sticker(sticker_id: int) Sticker [source]¶
Fetch a sticker from the guild
- Parameters:
sticker_id (int) – The ID of the sticker
- Returns:
The sticker object
- Return type:
Sticker
- async fetch_voice_state(member: Snowflake) VoiceState [source]¶
Fetches the voice state of the member
- Parameters:
member (Snowflake) – The member to fetch the voice state from
- Returns:
The voice state of the member
- Return type:
VoiceState
- Raises:
NotFound –
If the member is not in the guild - If the member is not in a voice channel
- get_partial_channel(channel_id: int) PartialChannel [source]¶
Get a partial channel object
- Parameters:
channel_id (int) – The ID of the channel
- Returns:
The partial channel object
- Return type:
PartialChannel
- get_partial_emoji(emoji_id: int) PartialEmoji [source]¶
Get a partial emoji object
- Parameters:
emoji_id (int) – The ID of the emoji
- Returns:
The partial emoji object
- Return type:
PartialEmoji
- get_partial_member(member_id: int) PartialMember [source]¶
Get a partial member object
- Parameters:
member_id (int) – The ID of the member
- Returns:
The partial member object
- Return type:
PartialMember
- get_partial_role(role_id: int) PartialRole [source]¶
Get a partial role object
- Parameters:
role_id (int) – The ID of the role
- Returns:
The partial role object
- Return type:
PartialRole
- get_partial_scheduled_event(id: int) PartialScheduledEvent [source]¶
Creates a partial scheduled event object.
- Parameters:
id (int) – The ID of the scheduled event.
- Returns:
The partial scheduled event object.
- Return type:
PartialScheduledEvent
- get_partial_sticker(sticker_id: int) PartialSticker [source]¶
Get a partial sticker object
- Parameters:
sticker_id (int) – The ID of the sticker
- Returns:
The partial sticker object
- Return type:
PartialSticker
- async kick(member: Member | PartialMember | int, *, reason: str | None = None) None [source]¶
Kick a member from the server
- Parameters:
member (Union[Member, PartialMember, int]) – The member to kick
reason (Optional[str]) – The reason for kicking the member
- async search_members(query: str, *, limit: int | None = 100) list[Member] [source]¶
Search for members in the guild
- Parameters:
query (str) – The query to search for
limit (Optional[int]) – The maximum amount of members to return
- Returns:
The members that matched the query
- Return type:
list[Member]
- Raises:
ValueError – If the limit is not between 1 and 1000
- async unban(member: Member | PartialMember | int, *, reason: str | None = None) None [source]¶
Unban a member from the server
- Parameters:
member (Union[Member, PartialMember, int]) – The member to unban
reason (Optional[str]) – The reason for unbanning the member
- class discord_http.guild.PartialScheduledEvent(*, state: DiscordAPI, id: int, guild_id: int)[source]¶
Bases:
PartialBase
- async edit(*, name: str | None = <MISSING>, description: str | None = <MISSING>, channel: PartialChannel | int | None = <MISSING>, external_location: str | None = <MISSING>, privacy_level: ~discord_http.enums.ScheduledEventPrivacyType | None = <MISSING>, entity_type: ~discord_http.enums.ScheduledEventEntityType | None = <MISSING>, status: ~discord_http.enums.ScheduledEventStatusType | None = <MISSING>, start_time: ~datetime.datetime | ~datetime.timedelta | int | None = <MISSING>, end_time: ~datetime.datetime | ~datetime.timedelta | int | None = <MISSING>, image: ~discord_http.file.File | bytes | None = <MISSING>, reason: str | None = None) ScheduledEvent [source]¶
Edit the event
- Parameters:
name (Optional[str]) – New name of the event
description (Optional[str]) – New description of the event
channel (Optional[Union["PartialChannel", int]]) – New channel of the event
privacy_level (Optional[ScheduledEventPrivacyType]) – New privacy level of the event
entity_type (Optional[ScheduledEventEntityType]) – New entity type of the event
status (Optional[ScheduledEventStatusType]) – New status of the event
start_time (Optional[Union[datetime, timedelta, int]]) – New start time of the event
end_time (Optional[Union[datetime, timedelta, int]]) – New end time of the event (only for external events)
image (Optional[Union[File, bytes]]) – New image of the event
reason (Optional[str]) – The reason for editing the event
- Returns:
The edited event
- Return type:
ScheduledEvent
- Raises:
ValueError – If the start_time is None
- async fetch() ScheduledEvent [source]¶
ScheduledEvent: Fetches more information about the event
- property guild: PartialGuild¶
The guild object this event is in
- Type:
PartialGuild
- property url: str¶
- class discord_http.guild.ScheduledEvent(*, state: DiscordAPI, data: dict)[source]¶
Bases:
PartialScheduledEvent