Channel Models#
- enum interactions.api.models.channel.ChannelType(value)[fuente]#
An enumerable object representing the type of channels.
- Member Type:
Valid values are as follows:
- GUILD_TEXT = <ChannelType.GUILD_TEXT: 0>#
- DM = <ChannelType.DM: 1>#
- GUILD_VOICE = <ChannelType.GUILD_VOICE: 2>#
- GROUP_DM = <ChannelType.GROUP_DM: 3>#
- GUILD_CATEGORY = <ChannelType.GUILD_CATEGORY: 4>#
- GUILD_ANNOUNCEMENT = <ChannelType.GUILD_ANNOUNCEMENT: 5>#
- GUILD_STORE = <ChannelType.GUILD_STORE: 6>#
- ANNOUNCEMENT_THREAD = <ChannelType.ANNOUNCEMENT_THREAD: 10>#
- PUBLIC_THREAD = <ChannelType.PUBLIC_THREAD: 11>#
- PRIVATE_THREAD = <ChannelType.PRIVATE_THREAD: 12>#
- GUILD_STAGE_VOICE = <ChannelType.GUILD_STAGE_VOICE: 13>#
- GUILD_DIRECTORY = <ChannelType.GUILD_DIRECTORY: 14>#
- GUILD_FORUM = <ChannelType.GUILD_FORUM: 15>#
- class interactions.api.models.channel.Thread(kwargs_dict=None, /, **other_kwargs)[fuente]#
Nuevo en la versión 4.0.2.
An object representing a thread.
Nota
This is a derivation of the base Channel, since a thread can be its own event.
- class interactions.api.models.channel.Channel(kwargs_dict=None, /, **other_kwargs)[fuente]#
A class object representing all types of channels.
- Variables:
id (Snowflake) – The (snowflake) ID of the channel.
type (ChannelType) – The type of channel.
guild_id (Optional[Snowflake]) – The ID of the guild if it is not a DM channel.
position (Optional[int]) – The position of the channel.
permission_overwrites (List[Overwrite]) – The non-synced permissions of the channel.
name (str) – The name of the channel.
topic (Optional[str]) – The description of the channel.
nsfw (Optional[bool]) – Whether the channel is NSFW.
last_message_id (Snowflake) – The ID of the last message sent.
bitrate (Optional[int]) – The audio bitrate of the channel.
user_limit (Optional[int]) – The maximum amount of users allowed in the channel.
rate_limit_per_user (Optional[int]) – The concurrent ratelimit for users in the channel.
recipients (Optional[List[User]]) – The recipients of the channel.
icon (Optional[str]) – The icon of the channel.
owner_id (Optional[Snowflake]) – The owner of the channel.
application_id (Optional[Snowflake]) – The application of the channel.
parent_id (Optional[Snowflake]) – The ID of the «parent»/main channel.
last_pin_timestamp (Optional[datetime]) – The timestamp of the last pinned message in the channel.
rtc_region (Optional[str]) – The region of the WebRTC connection for the channel.
video_quality_mode (Optional[int]) – The set quality mode for video streaming in the channel.
message_count (int) – The amount of messages in the channel.
member_count (Optional[int]) – The amount of members in the channel.
newly_created (Optional[bool]) – Boolean representing if a thread is created.
thread_metadata (Optional[ThreadMetadata]) – The thread metadata of the channel.
member (Optional[ThreadMember]) – The member of the thread in the channel.
default_auto_archive_duration (Optional[int]) – The set auto-archive time for all threads to naturally follow in the channel.
permissions (Optional[Permissions]) – The permissions of the channel.
flags (Optional[int]) – The flags of the channel.
total_message_sent (Optional[int]) – Number of messages ever sent in a thread.
default_thread_slowmode_delay (Optional[int]) – The default slowmode delay in seconds for threads, if this channel is a forum.
available_tags (Optional[List[Tags]]) – Tags in a forum channel, if any.
applied_tags (Optional[List[Snowflake]]) – The IDs of tags that have been applied to a thread, if any.
default_reaction_emoji (Optional[Emoji]) – Default reaction emoji for threads created in a forum, if any.
- property guild_id: Snowflake | None#
Nuevo en la versión 4.4.0.
Attempts to get the guild ID the channel is in.
- Devuelve:
The ID of the guild this channel belongs to.
- Tipo del valor devuelto:
Optional[Snowflake]
- property guild: Guild | None#
Nuevo en la versión 4.4.0.
Attempts to get the guild the channel is in.
- Devuelve:
The guild this channel belongs to.
- Tipo del valor devuelto:
- property typing: Awaitable | AbstractContextManager#
Nuevo en la versión 4.3.2.
Manages the typing of the channel. Use with await or async with
- Devuelve:
A manager for typing
- Tipo del valor devuelto:
- property mention: str#
Nuevo en la versión 4.1.0.
Returns a string that allows you to mention the given channel.
- Devuelve:
The string of the mentioned channel.
- Tipo del valor devuelto:
- property voice_states: List[VoiceState]#
Nuevo en la versión 4.4.0.
Returns all voice states this channel has. Only applicable for voice channels.
- Tipo del valor devuelto:
List[VoiceState]
- history(start_at=<interactions.MISSING>, reverse=False, maximum=inf, check=None)[fuente]#
Nuevo en la versión 4.3.2.
- Parámetros:
start_at (Optional[Union[int, str, Snowflake, Message]]) – The message to begin getting the history from
reverse (Optional[bool]) – Whether to only get newer message. Default False
maximum (Optional[int]) – A set maximum of messages to get before stopping the iteration
check (Optional[Callable[[Message], Union[bool, Awaitable[bool]]]]) – A custom check to ignore certain messages
- Devuelve:
An asynchronous iterator over the history of the channel
- Tipo del valor devuelto:
- async send(content=<interactions.MISSING>, *, tts=<interactions.MISSING>, attachments=<interactions.MISSING>, files=<interactions.MISSING>, embeds=<interactions.MISSING>, allowed_mentions=<interactions.MISSING>, stickers=<interactions.MISSING>, components=<interactions.MISSING>)[fuente]#
Nuevo en la versión 4.0.2.
Sends a message in the channel.
- Parámetros:
content (Optional[str]) – The contents of the message as a string or string-converted value.
tts (Optional[bool]) – Whether the message utilizes the text-to-speech Discord programme or not.
files (Optional[Union[File, List[File]]]) –
Nuevo en la versión 4.2.0.
A file or list of files to be attached to the message.
attachments (Optional[List[Attachment]]) –
Nuevo en la versión 4.3.0.
The attachments to attach to the message. Needs to be uploaded to the CDN first.
embeds (Optional[Union[Embed, List[Embed]]]) – An embed, or list of embeds for the message.
allowed_mentions (Optional[Union[AllowedMentions, dict]]) – The allowed mentions for the message.
stickers (Optional[List[Sticker]]) –
Nuevo en la versión 4.3.0.
A list of stickers to send with your message. You can send up to 3 stickers per message.
components (Optional[Union[ActionRow, Button, SelectMenu, List[Actionrow], List[Button], List[SelectMenu]]]) – A component, or list of components for the message.
- Devuelve:
The sent message as an object.
- Tipo del valor devuelto:
- async modify(name=<interactions.MISSING>, topic=<interactions.MISSING>, bitrate=<interactions.MISSING>, user_limit=<interactions.MISSING>, rate_limit_per_user=<interactions.MISSING>, position=<interactions.MISSING>, permission_overwrites=<interactions.MISSING>, parent_id=<interactions.MISSING>, nsfw=<interactions.MISSING>, archived=<interactions.MISSING>, auto_archive_duration=<interactions.MISSING>, locked=<interactions.MISSING>, reason=None)[fuente]#
Nuevo en la versión 4.0.2.
Edits the channel.
Nuevo en la versión 4.2.0: The fields
archived,auto_archive_durationandlocked. All require the provided channel to be a thread.- Parámetros:
name (Optional[str]) – The name of the channel, defaults to the current value of the channel
topic (Optional[str]) – The topic of that channel, defaults to the current value of the channel
bitrate (Optional[int]) – (voice channel only) The bitrate (in bits) of the voice channel, defaults to the current value of the channel
user_limit (Optional[int]) – (voice channel only) Maximum amount of users in the channel, defaults to the current value of the channel
rate_limit_per_user (Optional[int]) – Amount of seconds a user has to wait before sending another message (0-21600), defaults to the current value of the channel
position (Optional[int]) – Sorting position of the channel, defaults to the current value of the channel
parent_id (Optional[int]) – The id of the parent category for a channel, defaults to the current value of the channel
nsfw (Optional[bool]) – Whether the channel is nsfw or not, defaults to the current value of the channel
permission_overwrites (Optional[List[Overwrite]]) – The permission overwrites, if any
archived (Optional[bool]) –
Nuevo en la versión 4.2.0.
Whether the thread is archived
auto_archive_duration (Optional[int]) –
Nuevo en la versión 4.2.0.
The time after the thread is automatically archived. One of 60, 1440, 4320, 10080
locked (Optional[bool]) –
Nuevo en la versión 4.2.0.
Whether the thread is locked
reason (Optional[str]) – The reason for the edit
- Devuelve:
The modified channel as new object
- Tipo del valor devuelto:
- async set_name(name, *, reason=None)[fuente]#
Nuevo en la versión 4.1.0.
Sets the name of the channel.
- async set_topic(topic, *, reason=None)[fuente]#
Nuevo en la versión 4.1.0.
Sets the topic of the channel.
- async set_bitrate(bitrate, *, reason=None)[fuente]#
Nuevo en la versión 4.1.0.
Sets the bitrate of the channel.
- async set_user_limit(user_limit, *, reason=None)[fuente]#
Nuevo en la versión 4.1.0.
Sets the user_limit of the channel.
- async set_rate_limit_per_user(rate_limit_per_user, *, reason=None)[fuente]#
Nuevo en la versión 4.1.0.
Sets the amount of seconds a user has to wait before sending another message.
- async set_position(position, *, reason=None)[fuente]#
Nuevo en la versión 4.1.0.
Sets the position of the channel.
- async set_parent_id(parent_id, *, reason=None)[fuente]#
Nuevo en la versión 4.1.0.
Sets the parent_id of the channel.
- async set_nsfw(nsfw, *, reason=None)[fuente]#
Nuevo en la versión 4.1.0.
Sets the nsfw-flag of the channel.
- async archive(archived=True, *, reason=None)[fuente]#
Nuevo en la versión 4.2.0.
Sets the archived state of the thread.
- async set_auto_archive_duration(auto_archive_duration, *, reason=None)[fuente]#
Nuevo en la versión 4.2.0.
Sets the time after the thread is automatically archived.
- async lock(locked=True, *, reason=None)[fuente]#
Nuevo en la versión 4.2.0.
Sets the locked state of the thread.
- async add_member(member_id)[fuente]#
Nuevo en la versión 4.2.0.
This adds a member to the channel, if the channel is a thread.
- Parámetros:
member_id (int) – The id of the member to add to the channel
- async remove_member(member_id)[fuente]#
Nuevo en la versión 4.3.0.
This removes a member of the channel, if the channel is a thread.
- Parámetros:
member_id (int) – The id of the member to remove of the channel
- async unpin_message(message_id)[fuente]#
Nuevo en la versión 4.0.2.
Unpins a message from the channel.
- async publish_message(message_id)[fuente]#
Nuevo en la versión 4.0.2.
Publishes (API calls it crossposts) a message in the channel to any that is followed by.
- async get_pinned_messages()[fuente]#
Nuevo en la versión 4.0.2.
Get all pinned messages from the channel.
- Devuelve:
A list of pinned message objects.
- Tipo del valor devuelto:
List[Message]
- async get_message(message_id)[fuente]#
Nuevo en la versión 4.1.0.
Gets a message sent in that channel.
- async purge(amount, check=<interactions.MISSING>, before=<interactions.MISSING>, reason=None, bulk=True, force_bulk=False)[fuente]#
Nuevo en la versión 4.1.0.
Purges a given amount of messages from a channel. You can specify a check function to exclude specific messages.
Advertencia
Calling this method can lead to rate-limits when purging higher amounts of messages.
def check_pinned(message): return not message.pinned # This returns `True` only if the message is the message is not pinned await channel.purge(100, check=check_pinned) # This will delete the newest 100 messages that are not pinned in that channel
- Parámetros:
amount (int) – The amount of messages to delete
check (Optional[Callable[[Any], Union[bool, Awaitable[bool]]]]) – The function used to check if a message should be deleted. The message is only deleted if the check returns True
before (Optional[int]) – An id of a message to purge only messages before that message
bulk (Optional[bool]) –
Whether to use the bulk delete endpoint for deleting messages. This only works for 14 days
Distinto en la versión 4.4.0: Purge now automatically continues deleting messages even after the 14 days limit was hit. Check
force_bulkfor more information. If the 14 days span is exceeded the bot will encounter rate-limits more frequently.reason (Optional[st]) – The reason of the deletes
force_bulk (Optional[bool]) –
Nuevo en la versión 4.4.0: Whether to stop deleting messages when the 14 days bulk limit was hit, default
False
- Devuelve:
A list of the deleted messages
- Tipo del valor devuelto:
List[Message]
- async create_thread(name, type=ChannelType.PUBLIC_THREAD, auto_archive_duration=<interactions.MISSING>, invitable=<interactions.MISSING>, message_id=<interactions.MISSING>, reason=None)[fuente]#
Nuevo en la versión 4.1.0.
Creates a thread in the Channel.
- Parámetros:
name (str) – The name of the thread
auto_archive_duration (Optional[int]) – 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, defaults to public. ignored if creating thread from a message
invitable (Optional[bool]) – Boolean to display if the Thread is open to join or private.
message_id (Optional[Union[int, Snowflake, Message]]) – An optional message to create a thread from.
reason (Optional[str]) – An optional reason for the audit log
- Devuelve:
The created thread
- Tipo del valor devuelto:
- async create_invite(max_age=86400, max_uses=0, temporary=False, unique=False, target_type=<interactions.MISSING>, target_user_id=<interactions.MISSING>, target_application_id=<interactions.MISSING>, reason=None)[fuente]#
Creates an invite for the channel
- Parámetros:
max_age (Optional[int]) – Duration of invite in seconds before expiry, or 0 for never. between 0 and 604800 (7 days). Default 86400 (24h)
max_uses (Optional[int]) – Max number of uses or 0 for unlimited. between 0 and 100. Default 0
temporary (Optional[bool]) – Whether this invite only grants temporary membership. Default False
unique (Optional[bool]) – If true, don’t try to reuse a similar invite (useful for creating many unique one time use invites). Default False
target_type (Optional[InviteTargetType]) – The type of target for this voice channel invite
target_user_id (Optional[int]) – The id of the user whose stream to display for this invite, required if target_type is STREAM, the user must be streaming in the channel
target_application_id (Optional[int]) – The id of the embedded application to open for this invite, required if target_type is EMBEDDED_APPLICATION, the application must have the EMBEDDED flag
reason (Optional[str]) – The reason for the creation of the invite
- Tipo del valor devuelto:
- async get_history(limit=100)[fuente]#
Nuevo en la versión 4.2.0.
Obsoleto desde la versión 4.3.2: Use the
history()method insteadGets messages from the channel’s history.
- async get_members()[fuente]#
Nuevo en la versión 4.3.0.
Gets the list of thread members
- Devuelve:
The members of the thread.
- Tipo del valor devuelto:
List[ThreadMember]
- async create_tag(name, emoji_id=<interactions.MISSING>, emoji_name=<interactions.MISSING>)[fuente]#
Nuevo en la versión 4.3.2.
Create a new tag.
Nota
Can either have an emoji_id or an emoji_name, but not both. emoji_id is meant for custom emojis, emoji_name is meant for unicode emojis.
- async edit_tag(tag_id, name, emoji_name=<interactions.MISSING>, emoji_id=<interactions.MISSING>)[fuente]#
Nuevo en la versión 4.3.2.
Edits a tag
Nota
Can either have an emoji_id or an emoji_name, but not both. emoji_id is meant for custom emojis, emoji_name is meant for unicode emojis.
- Parámetros:
- Devuelve:
The modified tag
- Tipo del valor devuelto:
- async create_forum_post(name, content, auto_archive_duration=<interactions.MISSING>, applied_tags=<interactions.MISSING>, files=<interactions.MISSING>, rate_limit_per_user=<interactions.MISSING>, reason=None)[fuente]#
Nuevo en la versión 4.3.2.
Creates a new post inside a forum channel
- Parámetros:
name (str) – The name of the thread
auto_archive_duration (Optional[int]) – duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080
content (Union[dict, Message, str, Attachment, List[Attachment]]) – The content to send as first message.
applied_tags (Union[List[str], List[int], List[Tags], int, str, Tags]) – Tags to give to the created thread
files (Optional[List[File]]) – An optional list of files to send attached to the message.
rate_limit_per_user (Optional[int]) – Seconds a user has to wait before sending another message (0 to 21600), if given.
reason (Optional[str]) – An optional reason for the audit log
- Devuelve:
A channel of type
ChannelType.PUBLIC_THREAD- Tipo del valor devuelto:
- async get_permissions_for(member)[fuente]#
Nuevo en la versión 4.3.2.
Returns the permissions of the member in this specific channel.
Nota
The permissions returned by this function take into account role and user overwrites that can be assigned to channels or categories. If you don’t need these overwrites, look into
Member.get_guild_permissions().- Parámetros:
member (Member) – The member to get the permissions from
- Devuelve:
Permissions of the member in this channel
- Tipo del valor devuelto:
- async add_permission_overwrite(id, type=<interactions.MISSING>, allow=<interactions.MISSING>, deny=<interactions.MISSING>, reason=None)[fuente]#
Nuevo en la versión 4.4.0.
Adds a permission overwrite to the channel.
- Parámetros:
id (Union[int, str, Snowflake, User, Role]) – The ID of the User/Role to create the overwrite on.
type (Optional[Literal[0, 1, "0", "1"]]) – The type of the overwrite. 0 for Role 1 for User.
allow (Optional[Union[int, Permissions, str]]) – Permissions to allow
deny (Optional[Union[int, Permissions, str]]) – Permissions to deny
reason (Optional[str]) – The reason to be shown in the audit log
- Devuelve:
The updated channel
- Tipo del valor devuelto:
- async add_permission_overwrites(overwrites, reason=None)[fuente]#
Nuevo en la versión 4.4.0.
Add multiple overwrites to the channel.
- async overwrite_permission_overwrites(overwrites, reason=None)[fuente]#
Nuevo en la versión 4.4.0.
Overwrites the overwrites of the channel with new overwrites.
- class interactions.api.models.channel.ThreadMember(kwargs_dict=None, /, **other_kwargs)[fuente]#
A class object representing a member in a thread.
Nota
idonly shows if there are active intents involved with the member in the thread.- Variables:
id (Optional[Snowflake]) – The «ID» or intents of the member.
user_id (Snowflake) – The user ID of the member.
join_timestamp (datetime) – The timestamp of when the member joined the thread.
flags (int) – The bitshift flags for the member in the thread.
muted (bool) – Whether the member is muted or not.
- class interactions.api.models.channel.ThreadMetadata(kwargs_dict=None, /, **other_kwargs)[fuente]#
A class object representing the metadata of a thread.
Nota
invitablewill only show if the thread can have an invited created with the current cached permissions.- Variables:
archived (bool) – The current thread accessibility state.
auto_archive_duration (int) – The auto-archive time.
archive_timestamp (datetime) – The timestamp that the thread will be/has been closed at.
locked (bool) – The current message state of the thread.
invitable (Optional[bool]) – The ability to invite users to the thread.
- class interactions.api.models.channel.AsyncHistoryIterator(_client, obj, maximum=inf, start_at=<interactions.MISSING>, check=None, reverse=False)[fuente]#
Nuevo en la versión 4.3.2.
A class object that allows iterating through a channel’s history.
- Parámetros:
_client (HTTPClient) – The HTTPClient of the bot
obj (Union[int, str, Snowflake, Channel]) – The channel to get the history from
start_at (Optional[Union[int, str, Snowflake, Message]]) – The message to begin getting the history from
reverse (Optional[bool]) – Whether to only get newer message. Default False
check (Optional[Callable[[Message], Union[bool, Awaitable[bool]]]]) – A check to ignore certain messages
maximum (Optional[int]) – A set maximum of messages to get before stopping the iteration
- class interactions.api.models.channel.AsyncTypingContextManager(obj, _client)[fuente]#
Nuevo en la versión 4.3.2.
An async context manager for triggering typing.
- class interactions.api.models.channel.Tags(kwargs_dict=None, /, **other_kwargs)[fuente]#
Nuevo en la versión 4.3.2.
An object denoting a tag object within a forum channel.
Nota
If the emoji is custom, it won’t have name information.
- Variables:
name (str) – Name of the tag. The limit is up to 20 characters.
id (Snowflake) – ID of the tag. Can also be 0 if manually created.
moderated (bool) – A boolean denoting whether this tag can be removed/added by moderators with the
Permissions.MANAGE_THREADSpermission.emoji_name (Optional[str]) – The unicode character of the emoji.
emoji_id (Optional[Snowflake]) – The id of a guild’s custom emoji.
- async edit(channel_id, name, emoji_name=<interactions.MISSING>, emoji_id=<interactions.MISSING>)[fuente]#
Edits this tag
Nota
Can either have an emoji_id or an emoji_name, but not both. emoji_id is meant for custom emojis, emoji_name is meant for unicode emojis.
- Parámetros:
- Devuelve:
The modified tag
- Tipo del valor devuelto: