Melisa Models Guild#
Channel#
ChannelType#
- class ChannelType[source]#
Bases:
IntEnumChannel Type NOTE: Type 10, 11 and 12 are only available in Discord API v9.
- GUILD_TEXT#
A text channel within a server
- DM#
A direct message between users
- GUILD_VOICE#
A voice channel within a server
- GROUP_DM#
A direct message between multiple users
- GUILD_CATEGORY#
An organizational category that contains up to 50 channels
- GUILD_NEWS#
A channel that users can follow and crosspost into their own server
- GUILD_STORE#
A channel in which game developers can sell their game on Discord
- GUILD_NEWS_THREAD#
A temporary sub-channel within a
GUILD_NEWSchannel
- GUILD_PUBLIC_THREAD#
A temporary sub-channel within a
GUILD_TEXTchannel
- GUILD_PRIVATE_THREAD#
A temporary sub-channel within a
GUILD_TEXTchannel that is only viewable by those invited and those with the MANAGE_THREADS permission
- GUILD_STAGE_VOICE#
A voice channel for hosting events with an audience
VideoQualityModes#
Channel#
- application_id
- bitrate
- default_auto_archive_duration
- guild
- guild_id
- icon
- id
- last_message_id
- last_pin_timestamp
- member
- message_count
- name
- nsfw
- owner_id
- parent_id
- permission_overwrites
- permissions
- position
- rate_limit_per_user
- recipients
- rtc_region
- thread_metadata
- topic
- type
- user_limit
- video_quality_mode
- class Channel[source]#
Bases:
APIModelBaseRepresents a guild or DM channel within Discord
It will be never returned!
- id#
The id of this channel
- Type:
Snowflake
- type#
The type of channel
- Type:
int
- guild_id#
The id of the guild (may be missing for some channel objects received over gateway guild dispatches)
- Type:
Snowflake
- guild#
Object of guild where channel is
- Type:
Optional[
Guild]
- position#
Sorting position of the channel
- Type:
int
- permission_overwrites#
Explicit permission overwrites for members and roles
- Type:
typing.Any
- name#
The name of the channel (1-100 characters)
- Type:
str
- topic#
The channel topic (0-1024 characters)
- Type:
str
- nsfw#
Whether the channel is nsfw
- Type:
bool
- last_message_id#
The id of the last message sent in this channel (may not point to an existing or valid message)
- Type:
Snowflake
- bitrate#
The bitrate (in bits) of the voice channel
- Type:
int
- user_limit#
The user limit of the voice channel
- Type:
int
- rate_limit_per_user#
Amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission
MANAGE_MESSAGESandMANAGE_CHANNEL, are unaffected- Type:
int
- recipients#
The recipients of the DM
- Type:
typing.Any
- icon#
Icon hash of the group DM
- Type:
str
- owner_id#
Id of the creator of the group DM or thread
- Type:
Snowflake
- application_id#
Application id of the group DM creator if it is bot-created
- Type:
Snowflake
- parent_id#
For guild channels: id of the parent category for a channel (each parent category can contain up to 50 channels), for threads: id of the text channel this thread was created
- Type:
Snowflake
- last_pin_timestamp#
When the last pinned message was pinned. This may be null in events such as GUILD_CREATE when a message is not pinned.
- Type:
Timestamp
- rtc_region#
Voice region id for the voice channel, automatic when set to null
- Type:
str
- video_quality_mode#
The camera video quality mode of the voice channel, 1 when not present
- Type:
int
- message_count#
An approximate count of messages in a thread, stops counting at 50
- Type:
int
- thread_metadata#
Thread-specific fields not needed by other channels
- Type:
- member#
Thread member object for the current user, if they have joined the thread, only included on certain API endpoints
- Type:
typing.Any
- default_auto_archive_duration#
default duration that the clients (not the API) will use for newly created threads, in minutes, to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080
- Type:
int
- permissions#
Computed permissions for the invoking user in the channel, including overwrites, only included when part of the resolved data received on a slash command interaction
- Type:
str
- await delete(*, reason=None)[source]#
This function is a coroutine.
Delete a channel, or close a private message. Deleting a category does not delete its child channels; they will have their parent_id removed.
- Parameters:
reason (Optional[
str]) – The reason of the delete channel operation.- Raises:
NotFoundError – If channel is not found.
ForbiddenError – You do not have proper permissions to do the actions required.
- Returns:
Channel object.
- Return type:
- await edit(*, reason=None, **kwargs)[source]#
This function is a coroutine. Edit a channel with the specified keyword arguments.
- Parameters:
**kwargs – The keyword arguments to edit the channel with.
- Returns:
The updated channel object.
- Return type:
- to_dict()#
Transform the current object to a dictionary representation. Parameters that start with an underscore are not serialized.
TextChannel#
- clsTextChannel.from_dict
- asyncarchived_threads
- asyncbulk_delete_messages
- asynccreate_webhook
- asyncdelete
- asyncdelete_message
- asyncedit
- asyncfetch_message
- asynchistory
- asyncpins
- asyncpurge
- asyncsend
- asyncstart_thread_without_message
- defto_dict
- class TextChannel[source]#
Bases:
MessageableChannelA subclass of
Channelrepresenting text channels with all the same attributes.- await archived_threads(*, private=False, joined=False, before=None, limit=50)#
This function is a coroutine.
Returns archived threads in the channel.
Requires the
READ_MESSAGE_HISTORYpermission. If iterating over private threads thenMANAGE_THREADSpermission is also required.- Parameters:
before (Optional[Union[
Snowflake,) –
:param
Timestamp]]: Retrieve archived channels before the given date or ID. :param limit: The number of threads to retrieve.If None, retrieves every archived thread in the channel. Note, however, that this would make it a slow operation
- Parameters:
private (
bool) – Whether to retrieve private archived threads.joined (
bool) – Whether to retrieve private archived threads that you’ve joined. You cannot setjoinedtoTrueandprivatetoFalse.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have permissions to get archived threads.
- Returns:
The threads list object.
- Return type:
ThreadsList
- await bulk_delete_messages(messages, *, reason=None)#
This function is a coroutine.
Delete multiple messages in a single request. This method will not delete messages older than 2 weeks.
- Parameters:
messages (List[
Snowflake]) – The list of message IDs to delete (2-100).reason (Optional[
str]) – The reason of the bulk delete messages operation.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required. (You must have
MANAGE_MESSAGESpermission)
- await create_webhook(*, name=None, reason=None)[source]#
This function is a coroutine. Creates a new webhook and returns a webhook object on success. Requires the
MANAGE_WEBHOOKSpermission.An error will be returned if a webhook name (name) is not valid. A webhook name is valid if:
It does not contain the substring ‘clyde’ (case-insensitive)
It follows the nickname guidelines in the Usernames
and Nicknames documentation, with an exception that webhook names can be up to 80 characters
- Parameters:
name (Optional[
str]) – Name of the webhook (1-80 characters)reason (Optional[
str]) – The reason for create the webhook. Shows up on the audit log.
- await delete(*, reason=None)#
This function is a coroutine.
Delete a channel, or close a private message. Deleting a category does not delete its child channels; they will have their parent_id removed.
- Parameters:
reason (Optional[
str]) – The reason of the delete channel operation.- Raises:
NotFoundError – If channel is not found.
ForbiddenError – You do not have proper permissions to do the actions required.
- Returns:
Channel object.
- Return type:
- await delete_message(message_id, *, reason=None)#
This function is a coroutine.
Deletes only one specified message.
- Parameters:
message_id (Union[
int,str,Snowflake]) – Id of message to delete.reason (Optional[
str]) – The reason of the message delete operation.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required. (You must have
MANAGE_MESSAGESpermission)
- await edit(**kwargs)[source]#
This function is a coroutine. Edit a text channel with the specified keyword arguments.
- Parameters:
**kwargs – The keyword arguments to edit the channel with.
- Returns:
The updated channel object.
- Return type:
- await fetch_message(message_id)#
This function is a coroutine.
Returns a specific message in the channel.
- Parameters:
message_id (Optional[
Snowflake]) – Id of message to fetch.- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required.
- Returns:
Message object.
- Return type:
- classmethod from_dict(data)[source]#
Generate an text channel from the given data.
- Parameters:
data (
dict) – The dictionary to convert into a text channel.
- async for ... in history(limit=50, *, before=None, after=None, around=None)#
This function is a coroutine.
Returns a list of messages in this channel.
Examples
Flattening messages into a list:
messages = [message async for message in channel.history(limit=111)]
All parameters are optional.
- Parameters:
limit (Optional[
Snowflake]) – Max number of messages to return (1-100).around (Optional[
Snowflake]) – Get messages around this message ID.before (Optional[
Snowflake]) – Get messages before this message ID.after (Optional[
Snowflake]) – Get messages after this message ID.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required.
- Returns:
An iterator of messages.
- Return type:
AsyncIterator[
Message]
- async for ... in pins()#
This function is a coroutine.
Retrieves all messages that are currently pinned in the channel.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
- Returns:
AsyncIterator of Message objects.
- Return type:
AsyncIterator[
Message]
- await purge(limit=50, *, before=None, after=None, around=None, reason=None)#
This function is a coroutine.
Purges a list of messages that meet the criteria specified in parameters. This method will not delete messages older than 2 weeks.
- Parameters:
limit (Optional[
Snowflake]) – Max number of messages to purge.around (Optional[
Snowflake]) – Get messages around this message ID.before (Optional[
Snowflake]) – Get messages before this message ID.after (Optional[
Snowflake]) – Get messages after this message ID.reason (Optional[
str]) – The reason of the channel purge operation.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required. (You must have
MANAGE_MESSAGESpermission)
- await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, allowed_mentions=None, delete_after=None)#
This function is a coroutine.
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through str(content).
- Parameters:
content (Optional[
str]) – The content of the message to send.tts (Optional[
bool]) – Whether the message should be sent using text-to-speech.embed (Optional[
Embed]) – Embedembeds (Optional[List[
Embed]]) – List of embedsfile (Optional[
File]) – Filefiles (Optional[List[
File]]) – List of filesallowed_mentions (Optional[
AllowedMentions]) – Controls the mentions being processed in this message.delete_after (Optional[
int]) – Provided value must be an int. if provided, deletes message after some seconds. May raiseForbiddenErrororNotFoundError.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have the proper permissions to send the message.
BadRequestError – Some of specified parameters is invalid.
- await start_thread_without_message(*, name, type, auto_archive_duration=None, invitable=None, rate_limit_per_user=None, reason=None)#
This function is a coroutine.
Creates a new thread that is not connected to an existing message. The created thread defaults to a
GUILD_PRIVATE_THREAD.Creating a private thread requires the server to be boosted. The guild features will indicate if that is possible for the guild. The 3 day and 7 day archive durations require the server to be boosted. The guild features will indicate if that is possible for the guild.
- Parameters:
name (Optional[
str]) – The name of the thread. 1-100 characters.auto_archive_duration (Optional[
int]) – The duration in minutes to automatically archive the thread after recent activity, can be set to:60,1440,4320,10080.type (Optional[
ChannelType]) – The type of thread to create.invitable (Optional[
bool]) – Whether non-moderators can add other non-moderators to a thread; only available when creating a private thread.rate_limit_per_user (Optional[
int]) – Amount of seconds a user has to wait before sending another message. (0-21600)reason (Optional[
str]) – The reason of the thread creation.
- Raises:
ForbiddenError – You do not have proper permissions to do the actions required.
HTTPException – The request to perform the action failed with other http exception.
- Returns:
Union[
Channel,Any] – The created thread.
- to_dict()#
Transform the current object to a dictionary representation. Parameters that start with an underscore are not serialized.
NoneTypedChannel#
- class NoneTypedChannel[source]#
Bases:
ChannelIt represents a channel, that is unknown, so we don’t know this type of the channel, And also we can’t convert it to something, but it has every method, that Channel has.
You can use
rawattribute to access to the original data, returned from the discord.- id#
Id of the channel
- Type:
Snowflake
- raw#
Raw value channel data (returned from the discord)
- Type:
Dict[
str, Any]
- await delete(*, reason=None)#
This function is a coroutine.
Delete a channel, or close a private message. Deleting a category does not delete its child channels; they will have their parent_id removed.
- Parameters:
reason (Optional[
str]) – The reason of the delete channel operation.- Raises:
NotFoundError – If channel is not found.
ForbiddenError – You do not have proper permissions to do the actions required.
- Returns:
Channel object.
- Return type:
- await edit(*, reason=None, **kwargs)#
This function is a coroutine. Edit a channel with the specified keyword arguments.
- Parameters:
**kwargs – The keyword arguments to edit the channel with.
- Returns:
The updated channel object.
- Return type:
- classmethod from_dict(data)[source]#
Generate a channel with unknown type from the given data.
- Parameters:
data (
dict) – The dictionary to convert into an unknown channel.
- to_dict()#
Transform the current object to a dictionary representation. Parameters that start with an underscore are not serialized.
Member#
GuildMember#
- clsGuildMember.from_dict
- asyncadd_role
- defavatar_url
- asyncban
- asynckick
- defmake_guild_avatar_url
- asyncremove_role
- asynctimeout
- defto_dict
- class GuildMember[source]#
Bases:
APIModelBaseThis model represents a guild member.
The field user won’t be included in the member object attached to ``MESSAGE_CREATE`` and ``MESSAGE_UPDATE`` gateway events.
In
GUILD_events,pendingwill always be included as true or false. In nonGUILD_events which can only be triggered by non-pendingusers,pendingwill not be included.- nick#
This user’s guild nickname
- Type:
Optional[
str]
- avatar#
The member’s guild avatar hash
- Type:
Optional[
str]
- role_ids#
List of role ids.
- Type:
List[
Snowflake]
- joined_at#
When the user joined the guild
- Type:
Optional[
Timestamp]
When the user started boosting the guild
- Type:
Optional[
Timestamp]
- is_deaf#
Whether the user is deafened in voice channels
- Type:
bool
- is_mute#
Whether the user is muted in voice channels
- Type:
bool
- pending#
the user has not yet passed the guild’s Membership Screening requirements
- Type:
Optional[
bool]
- permissions#
Total permissions of the member in the channel, including overwrites, returned when in the interaction object
- Type:
Optional[
str]
- communication_disabled_until#
When the user’s timeout will expire and the user will be able to communicate in the guild again, null or a time in the past if the user is not timed out
- Type:
Optional[
Timestamp]
- guild_id#
The id of the guild this member belongs to.
- Type:
List[
Snowflake]
- await add_role(role_id, *, reason=None)[source]#
This function is a coroutine.
Add a role to a guild member.
Required permissions:
MANAGE_ROLES- Parameters:
role_id (Optional[
int]) – Id of role to add.reason (Optional[
str]) – The reason of the action.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required.
BadRequestError – You provided a wrong guild, user or something else
- await ban(*, delete_message_days=0, reason=None)[source]#
This function is a coroutine.
Ban guild member, and optionally delete previous messages sent by the banned user.
Required permissions:
BAN_MEMBERS- Parameters:
delete_message_days (Optional[
int]) – Number of days to delete messages for (0-7)reason (Optional[
str]) – The reason of the action.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required.
BadRequestError – You provided a wrong guild, user or something else
- classmethod from_dict(data)[source]#
Generate a guild member from the given data.
- Parameters:
data (
dict) – The dictionary to convert into a guild member.
- await kick(*, reason=None)[source]#
This function is a coroutine.
Kicks member from a guild.
Required permissions:
KICK_MEMBERS- Parameters:
reason (Optional[
str]) – The reason of the action.- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required.
- make_guild_avatar_url(size=1024)[source]#
User guild avatar url (from the Discord CDN server)
- Parameters:
size (int) – The size to set for the URL, defaults to 1024. Can be any power of two between 16 and 4096.
- await remove_role(role_id, *, reason=None)[source]#
This function is a coroutine.
Add a role to remove from a guild member.
Required permissions:
MANAGE_ROLES- Parameters:
role_id (Optional[
int]) – Id of role to remove.reason (Optional[
str]) – The reason of the action.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required.
BadRequestError – You provided a wrong guild, user or something else
- await timeout(*, duration=None, until=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.
Required permissions:
MODERATE_MEMBERS- duration: Optional[class:float]
The duration (seconds) of the member’s timeout. Set to
Noneto remove the timeout. Supports up to 28 days in the future.- until: Optional[
datetime.datetime] The expiry date/time of the member’s timeout. Set to
Noneto remove the timeout. Supports up to 28 days in the future.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required.
BadRequestError – You provided a wrong type of argument/
- Returns:
This member object.
- Return type:
- to_dict()#
Transform the current object to a dictionary representation. Parameters that start with an underscore are not serialized.
Guild#
DefaultMessageNotificationLevel#
ExplicitContentFilterLevel#
MFALevel#
VerificationLevel#
- class VerificationLevel[source]#
Bases:
IntEnumVerification level on the server
- NONE#
Unrestricted
- LOW#
Must have verified email on account
- MEDIUM#
Must be registered on Discord for longer than 5 minutes
- HIGH#
Must be a member of the server for longer than 10 minutes
- VERY_HIGH#
Must have a verified phone number
GuildNSFWLevel#
SystemChannelFlags#
- class SystemChannelFlags[source]#
Bases:
IntEnumSystem channel flags
- SUPPRESS_JOIN_NOTIFICATIONS#
Suppress member join notifications
- SUPPRESS_PREMIUM_SUBSCRIPTIONS#
Suppress server boost notifications
- SUPPRESS_GUILD_REMINDER_NOTIFICATIONS#
Suppress server setup tips
- SUPPRESS_JOIN_NOTIFICATION_REPLIES#
Hide member join sticker reply buttons
Guild#
- afk_channel_id
- afk_timeout
- application_id
- approximate_member_count
- approximate_presence_count
- banner
- channels
- created_at
- default_message_notifications
- description
- discovery_splash
- emojis
- explicit_content_filter
- features
- guild_scheduled_events
- icon
- icon_hash
- id
- large
- max_members
- max_presences
- max_video_channel_users
- member_count
- members
- mfa_level
- name
- nsfw_level
- owner
- owner_id
- permissions
- preferred_locale
- premium_progress_bar_enabled
- premium_subscription_count
- premium_tier
- presences
- public_updates_channel_id
- region
- roles
- rules_channel_id
- splash
- stage_instances
- stickers
- system_channel_flags
- system_channel_id
- threads
- unavailable
- vanity_url_code
- verification_level
- voice_states
- welcome_screen
- widget_channel_id
- widget_enabled
- clsGuild.from_dict
- asyncactive_threads
- asynccreate_channel
- asynccreate_emoji
- asyncdelete_emoji
- asyncedit_emoji
- asyncfetch_emoji
- asyncfetch_emojis
- deficon_url
- defto_dict
- asyncunban
- class Guild[source]#
Bases:
APIModelBase- Guilds in Discord represent an isolated collection of users and channels,
and are often referred to as “servers” in the UI.
- id#
Guild id
- Type:
Snowflake
- name#
Guild name (2-100 characters, excluding trailing and leading whitespace)
- Type:
str
- icon#
Icon hash
- Type:
str
- icon_hash#
Icon hash, returned when in the template object
- Type:
APINullable[
str]
- splash#
Splash hash
- Type:
Optional[
str]
- discovery_splash#
Discovery splash hash; only present for guilds with the “DISCOVERABLE” feature
- Type:
APINullable[
str]
- owner#
True if the user is the owner of the guild
- Type:
bool
- owner_id#
Id of owner
- Type:
APINullable[
Snowflake]
- permissions#
Total permissions for the user in the guild (excludes overwrites)
- Type:
APINullable[
str]
- region#
Voice region id for the guild (deprecated)
- Type:
APINullable[
str]
- afk_channel_id#
Id of afk channel
- Type:
APINullable[
Snowflake]
- afk_timeout#
Afk timeout in seconds
- Type:
int
- widget_enabled#
True if the server widget is enabled
- Type:
bool
- widget_channel_id#
The channel id that the widget will generate an invite to, or null if set to no invite
- Type:
Snowflake
- verification_level#
Verification level required for the guild
- Type:
int
- default_message_notifications#
Default message notifications level
- Type:
APINullable[
int]
- explicit_content_filter#
Explicit content filter level
- Type:
int
- features#
Enabled guild features
- Type:
APINullable[List[
str]]
- roles#
Roles in the guild
- Type:
Dict[
Snowflake,Role]
- emojis#
Custom guild emojis
- Type:
Dict[
Snowflake,Emoji]
- mfa_level#
Required MFA level for the guild
- Type:
int
- application_id#
Application id of the guild creator if it is bot-created
- Type:
APINullable[
Snowflake]
- system_channel_id#
The id of the channel where guild notices such as welcome messages and boost events are posted
- Type:
APINullable[
Snowflake]
- system_channel_flags#
System channel flags
- Type:
int
- rules_channel_id#
The id of the channel where Community guilds can display rules and/or guidelines
- Type:
APINullable[
Snowflake]
- large#
True if this is considered a large guild
- Type:
APINullable[
bool]
True if this guild is unavailable due to an outage
- Type:
bool
- member_count#
Total number of members in this guild
- Type:
APINullable[
int]
- voice_states#
States of members currently in voice channels; lacks the guild_id key
- Type:
Optional[Union[List, melisa.utils.types.UndefinedType]]
- members#
Users in the guild
- Type:
APINullable[
GuildMember]
- threads#
All active threads in the guild that current user has permission to view
- Type:
APINullable[Dict[
Thread]]
- presences#
Presences of the members in the guild, will only include non-offline members if the size is greater than large threshold
- Type:
APINullable[
typing.Any]
- max_presences#
The maximum number of presences for the guild (null is always returned, apart from the largest of guilds)
- Type:
APINullable[
int]
- max_members#
The maximum number of members for the guild
- Type:
APINullable[
int]
- vanity_url_code#
The vanity url code for the guild
- Type:
APINullable[
str]
- description#
The description of a Community guild
- Type:
APINullable[
str]
- banner#
Banner hash
- Type:
Optional[
str]
Premium tier (Server Boost level)
- Type:
APINullable[
str]
The number of boosts this guild currently has
- Type:
APINullable[
int]
- preferred_locale#
The preferred locale of a Community guild; used in server discovery and notices from Discord, and sent in interactions; defaults to “en-US”
- Type:
APINullable[
str]
- public_updates_channel_id#
The id of the channel where admins and moderators of Community guilds receive notices from Discord
- Type:
APINullable[
Snowflake]
- max_video_channel_users#
The maximum amount of users in a video channel
- Type:
APINullable[
int]
- approximate_member_count#
Approximate number of members in this guild, returned from the GET /guilds/<id> endpoint when with_counts is true
- Type:
APINullable[
int]
- approximate_presence_count#
Approximate number of non-offline members in this guild, returned from the GET /guilds/<id> endpoint when with_counts is true
- Type:
APINullable[
int]
- nsfw_level#
Guild NSFW level
- Type:
APINullable[
int]
Whether the guild has the boost progress bar enabled
- Type:
APINullable[
bool]
- stage_instances#
Stage instances in the guild
- Type:
APINullable[
typing.Any]
- stickers#
Custom guild stickers
- Type:
APINullable[
typing.Any]
- welcome_screen#
The welcome screen of a Community guild, shown to new members, returned in an Invite’s guild object
- Type:
APINullable[
typing.Any]
- guild_scheduled_events#
The scheduled events in the guild
- Type:
APINullable[
typing.Any]
- await active_threads()[source]#
This function is a coroutine.
Returns a Threadslist of active
Threadthat the client can access.This includes both private and public threads.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
- Returns:
The active threads.
- Return type:
ThreadsList
- await create_channel(*, reason=None, **kwargs)[source]#
This function is a coroutine.
Create a new channel object for the guild.
- Parameters:
name (str) – channel name (1-100 characters)
type (Optional[
int]) – the type of channeltopic (Optional[
str]) – channel topic (0-1024 characters)bitrate (Optional[
int]) – the bitrate (in bits) of the voice channel (voice only)user_limit (Optional[
int]) – the user limit of the voice channel (voice only)rate_limit_per_user (Optional[
int]) – amount of seconds a user has to wait before sending another message (0-21600) bots, as well as users with the permissionMANAGE_MESSAGESorMANAGE_CHANNEL, are unaffectedposition (Optional[
int]) – sorting position of the channelpermission_overwrites (Optional[List[Any]]) – the channel’s permission overwrites
parent_id (Optional[
Snowflake]) – id of the parent category for a channelnsfw (Optional[
bool]) – whether the channel is nsfwreason (Optional[
str]) – audit log reason |default|None
- Raises:
BadRequestError – If some specified parameters are wrong.
ForbiddenError – You do not have proper permissions to do the actions required. This method requires MANAGE_CHANNELS permission. Setting MANAGE_ROLES permission in channels is only possible for guild administrators.
- Returns:
New channel object.
- Return type:
- await create_emoji(emoji_name, emoji_image, *, reason=None, role_id=None)[source]#
This function is a coroutine.
Create a new emoji for the guild. Requires the MANAGE_EMOJIS_AND_STICKERS permission. Returns the new emoji object on success. Fires a Guild Emojis Update Gateway event.
- Parameters:
emoji_name (Optional[
str]) – Name of the emojiemoji_image (Optional[
str]) – The 128x128 emoji imagereason (Optional[
str]) – The reason of the actionrole_id (List[Union[
int,str,Snowflake]]) – Roles allowed to use this emoji
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required.
BadRequestError – You provided a wrong guild
- property created_at#
Returns the guild’s creation time in UTC.
- Type:
datetime.datetime
- await delete_emoji(emoji_id, *, reason=None)[source]#
This function is a coroutine.
Delete the given emoji. Requires the MANAGE_EMOJIS_AND_STICKERS permission. Returns 204 No Content on success. Fires a Guild Emojis Update Gateway event.
- Parameters:
emoji_id (Union[
int,str,Snowflake]) – The ID of the emoji that we will deletereason (Optional[
str]) – The reason of the action
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required.
BadRequestError – You provided a wrong guild and emoji
- await edit_emoji(emoji_id, emoji_name, *, reason=None, role_id=None)[source]#
This function is a coroutine.
Modify the given emoji. Requires the MANAGE_EMOJIS_AND_STICKERS permission. Returns the updated emoji object on success.
- Parameters:
emoji_id (Union[
int,str,Snowflake]) – The ID of the emoji that we will modifyemoji_name (Optional[
str]) – Name of the emojireason (Optional[
str]) – The reason of the actionrole_id (Union[
int,str,Snowflake]) – Roles allowed to use this emoji
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required.
BadRequestError – You provided a wrong guild and emoji
- await fetch_emoji(emoji_id)[source]#
This function is a coroutine.
Get emoji from guild
- Parameters:
emoji_id (Union[
int,str,Snowflake]) – The ID of the emoji that we will get- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required.
BadRequestError – You provided a wrong guild and emoji
- await fetch_emojis()[source]#
This function is a coroutine.
Getting all emojis from guild
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required.
BadRequestError – You provided a wrong guild
- classmethod from_dict(data)[source]#
Generate a guild from the given data.
- Parameters:
data (
dict) – The dictionary to convert into a guild.
- to_dict()#
Transform the current object to a dictionary representation. Parameters that start with an underscore are not serialized.
- await unban(user_id, *, reason=None)[source]#
This function is a coroutine.
Remove the ban for a user.
Required permissions:
BAN_MEMBERS- Parameters:
user_id (Union[
int,str,Snowflake]) – Id of user to operate with.reason (Optional[
str]) – The reason of the action.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required.
BadRequestError – You provided a wrong guild, user or something else Or if the user is not banned
Thread#
Thread#
- clsThread.from_dict
- asyncadd_user
- asyncarchived_threads
- asyncbulk_delete_messages
- asyncdelete
- asyncdelete_message
- asyncedit
- asyncfetch_message
- asynchistory
- asyncjoin
- asyncleave
- asyncpins
- asyncpurge
- asyncremove_user
- asyncsend
- defto_dict
- class Thread[source]#
Bases:
MessageableChannelA subclass of
Channelfor threads with all the same attributes.- await add_user(user_id)[source]#
This function is a coroutine.
Adds a user to this thread.
You must have
SEND_MESSAGESpermission to add a user to a public thread. If the thread is private thenSEND_MESSAGESand eitherCREATE_PRIVATE_THREADSor manage_messages permissions is required to add a user to the thread.- Parameters:
user_id (
Snowflake) – Id of user to add to the thread.- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have permissions to add the user to the thread.
- await archived_threads(*, private=False, joined=False, before=None, limit=50)#
This function is a coroutine.
Returns archived threads in the channel.
Requires the
READ_MESSAGE_HISTORYpermission. If iterating over private threads thenMANAGE_THREADSpermission is also required.- Parameters:
before (Optional[Union[
Snowflake,) –
:param
Timestamp]]: Retrieve archived channels before the given date or ID. :param limit: The number of threads to retrieve.If None, retrieves every archived thread in the channel. Note, however, that this would make it a slow operation
- Parameters:
private (
bool) – Whether to retrieve private archived threads.joined (
bool) – Whether to retrieve private archived threads that you’ve joined. You cannot setjoinedtoTrueandprivatetoFalse.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have permissions to get archived threads.
- Returns:
The threads list object.
- Return type:
ThreadsList
- await bulk_delete_messages(messages, *, reason=None)#
This function is a coroutine.
Delete multiple messages in a single request. This method will not delete messages older than 2 weeks.
- Parameters:
messages (List[
Snowflake]) – The list of message IDs to delete (2-100).reason (Optional[
str]) – The reason of the bulk delete messages operation.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required. (You must have
MANAGE_MESSAGESpermission)
- await delete(*, reason=None)#
This function is a coroutine.
Delete a channel, or close a private message. Deleting a category does not delete its child channels; they will have their parent_id removed.
- Parameters:
reason (Optional[
str]) – The reason of the delete channel operation.- Raises:
NotFoundError – If channel is not found.
ForbiddenError – You do not have proper permissions to do the actions required.
- Returns:
Channel object.
- Return type:
- await delete_message(message_id, *, reason=None)#
This function is a coroutine.
Deletes only one specified message.
- Parameters:
message_id (Union[
int,str,Snowflake]) – Id of message to delete.reason (Optional[
str]) – The reason of the message delete operation.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required. (You must have
MANAGE_MESSAGESpermission)
- await edit(*, reason=None, **kwargs)#
This function is a coroutine. Edit a channel with the specified keyword arguments.
- Parameters:
**kwargs – The keyword arguments to edit the channel with.
- Returns:
The updated channel object.
- Return type:
- await fetch_message(message_id)#
This function is a coroutine.
Returns a specific message in the channel.
- Parameters:
message_id (Optional[
Snowflake]) – Id of message to fetch.- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required.
- Returns:
Message object.
- Return type:
- classmethod from_dict(data)[source]#
Generate an thread from the given data.
- Parameters:
data (
dict) – The dictionary to convert into a thread.
- async for ... in history(limit=50, *, before=None, after=None, around=None)#
This function is a coroutine.
Returns a list of messages in this channel.
Examples
Flattening messages into a list:
messages = [message async for message in channel.history(limit=111)]
All parameters are optional.
- Parameters:
limit (Optional[
Snowflake]) – Max number of messages to return (1-100).around (Optional[
Snowflake]) – Get messages around this message ID.before (Optional[
Snowflake]) – Get messages before this message ID.after (Optional[
Snowflake]) – Get messages after this message ID.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required.
- Returns:
An iterator of messages.
- Return type:
AsyncIterator[
Message]
- await join()[source]#
This function is a coroutine.
Joins this thread.
You must have
SEND_MESSAGES_IN_THREADSto join a thread. If the thread is private,MANAGE_THREADSis also needed.- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have permissions to join the thread.
- await leave()[source]#
This function is a coroutine.
Leaves this thread.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
- async for ... in pins()#
This function is a coroutine.
Retrieves all messages that are currently pinned in the channel.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
- Returns:
AsyncIterator of Message objects.
- Return type:
AsyncIterator[
Message]
- await purge(limit=50, *, before=None, after=None, around=None, reason=None)#
This function is a coroutine.
Purges a list of messages that meet the criteria specified in parameters. This method will not delete messages older than 2 weeks.
- Parameters:
limit (Optional[
Snowflake]) – Max number of messages to purge.around (Optional[
Snowflake]) – Get messages around this message ID.before (Optional[
Snowflake]) – Get messages before this message ID.after (Optional[
Snowflake]) – Get messages after this message ID.reason (Optional[
str]) – The reason of the channel purge operation.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have proper permissions to do the actions required. (You must have
MANAGE_MESSAGESpermission)
- await remove_user(user_id)[source]#
This function is a coroutine.
Removes a user from this thread.
You must have
MANAGE_THREADSor be the creator of the thread to remove a user.- Parameters:
user_id (
Snowflake) – Id of user to add to the thread.- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have permissions to remove the user to the thread.
- await send(content=None, *, tts=False, embed=None, embeds=None, file=None, files=None, allowed_mentions=None, delete_after=None)#
This function is a coroutine.
Sends a message to the destination with the content given.
The content must be a type that can convert to a string through str(content).
- Parameters:
content (Optional[
str]) – The content of the message to send.tts (Optional[
bool]) – Whether the message should be sent using text-to-speech.embed (Optional[
Embed]) – Embedembeds (Optional[List[
Embed]]) – List of embedsfile (Optional[
File]) – Filefiles (Optional[List[
File]]) – List of filesallowed_mentions (Optional[
AllowedMentions]) – Controls the mentions being processed in this message.delete_after (Optional[
int]) – Provided value must be an int. if provided, deletes message after some seconds. May raiseForbiddenErrororNotFoundError.
- Raises:
HTTPException – The request to perform the action failed with other http exception.
ForbiddenError – You do not have the proper permissions to send the message.
BadRequestError – Some of specified parameters is invalid.
- to_dict()#
Transform the current object to a dictionary representation. Parameters that start with an underscore are not serialized.
ThreadMember#
- class ThreadMember[source]#
Bases:
APIModelBaseRepresents a Discord Thread Member object
- id#
The id of the thread
- Type:
Optional[
Snowflake]
- user_id#
The id of the user
- Type:
Optional[
Snowflake]
- join_timestamp#
The time the current user last joined the thread
- Type:
Timestamp
- flags#
Any user-thread settings, currently only used for notifications
- Type:
int
- classmethod from_dict(data)[source]#
Generate a thread member object from the given data.
- Parameters:
data (
dict) – The dictionary to convert into thread member.
- to_dict()#
Transform the current object to a dictionary representation. Parameters that start with an underscore are not serialized.
ThreadMetadata#
- class ThreadMetadata[source]#
Bases:
APIModelBaseRepresents a Discord Thread Metadata object
- archived#
Whether the thread is archived
- Type:
bool
- auto_archive_duration#
Duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080
- Type:
int
- archive_timestamp#
Timestamp when the thread’s archive status was last changed, used for calculating recent activity
- Type:
Timestamp
- locked#
Whether the thread is locked; when a thread is locked, only users with
MANAGE_THREADScan unarchive it- Type:
bool
- invitable#
Whether non-moderators can add other non-moderators to a thread; only available on private threads
- Type:
Optional[
bool]
- create_timestamp#
Timestamp when the thread was created; only populated for threads created after 2022-01-09
- Type:
Optional[
Timestamp]
- classmethod from_dict(data)[source]#
Generate a thread metadata object from the given data.
- Parameters:
data (
dict) – The dictionary to convert into thread metadata.
- to_dict()#
Transform the current object to a dictionary representation. Parameters that start with an underscore are not serialized.
ThreadsList#
- clsThreadsList.from_dict
- defto_dict
- class ThreadsList[source]#
Bases:
APIModelBaseA class representing a list of channel threads from the Discord API.
- members#
Async iterator of thread members.
- Type:
List[
ThreadMember]
- has_more#
Whether there are potentially additional threads that could be returned on a subsequent cal
- Type:
Optional[
bool]
- classmethod from_dict(data)[source]#
Generate an threads list from the given dict.
- Parameters:
data (
dict) – The dictionary to convert into an threads list.
- to_dict()#
Transform the current object to a dictionary representation. Parameters that start with an underscore are not serialized.
Webhook#
WebhookType#
- class WebhookType[source]#
Bases:
IntEnumWebhook Type
- INCOMING#
Incoming Webhooks can post messages to channels with a generated token
- CHANNEL_FOLLOWER#
Channel Follower Webhooks are internal webhooks used with Channel Following to post new messages into channels
- APPLICATION#
Application webhooks are webhooks used with Interactions
Webhook#
- clsWebhook.from_dict
- asyncdelete
- asyncmodify
- defto_dict
- class Webhook[source]#
Bases:
APIModelBaseWebhooks are a low-effort way to post messages to channels in Discord. They do not require a bot user or authentication to use.
- id#
The id of the webhook
- Type:
Snowflake
- type#
The type of the webhook
- Type:
int
- guild_id#
The guild id this webhook is for, if any
- Type:
Snowflake
- channel_id#
The channel id this webhook is for, if any
- Type:
Snowflake
- user#
The user this webhook was created by (not returned when getting a webhook with its token)
- Type:
- name#
The default name of the webhook
- Type:
str
- avatar#
The default user avatar hash of the webhook
- Type:
str
- token#
The secure token of the webhook (returned for Incoming Webhooks)
- Type:
str
- application_id#
The bot/OAuth2 application that created this webhook
- Type:
Snowflake
- source_guild#
The guild of the channel that this webhook is following (returned for Channel Follower Webhooks)
- Type:
- source_channel#
The channel that this webhook is following (returned for Channel Follower Webhooks)
- Type:
- url#
The url used for executing the webhook (returned by the webhooks OAuth2 flow)
- Type:
str
- await delete(*, reason=None)[source]#
This function is a coroutine. Delete a webhook permanently. Requires the
MANAGE_WEBHOOKSpermission. Returns a204 No Contentresponse on success.- Parameters:
reason (Optional[
str]) – The reason for delete the webhook. Shows up on the audit log.
- classmethod from_dict(data)[source]#
Generate a webhook from the given data.
- Parameters:
data (
dict) – The dictionary to convert into a webhook.
- await modify(*, name=None, channel_id=None, reason=None)[source]#
This function is a coroutine. Modify a webhook. Requires the
MANAGE_WEBHOOKS permission. Returns the updated webhook object on success.- Parameters:
name (Optional[
str]) – The default name of the webhookchannel_id (Optional[
Snowflake]) – The new channel id this webhook should be moved toreason (Optional[
str]) – The reason for modify the webhook. Shows up on the audit log.
- to_dict()#
Transform the current object to a dictionary representation. Parameters that start with an underscore are not serialized.