Channel Models#
- enum interactions.api.models.channel.ChannelType(value)[sorgente]#
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)[sorgente]#
Nuovo nella versione 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)[sorgente]#
A class object representing all types of channels.
- Variabili:
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#
Nuovo nella versione 4.4.0.
Attempts to get the guild ID the channel is in.
- Ritorna:
The ID of the guild this channel belongs to.
- Tipo di ritorno:
Optional[Snowflake]
- property guild: Guild | None#
Nuovo nella versione 4.4.0.
Attempts to get the guild the channel is in.
- Ritorna:
The guild this channel belongs to.
- Tipo di ritorno:
- property typing: Awaitable | AbstractContextManager#
Nuovo nella versione 4.3.2.
Manages the typing of the channel. Use with await or async with
- Ritorna:
A manager for typing
- Tipo di ritorno:
- property mention: str#
Nuovo nella versione 4.1.0.
Returns a string that allows you to mention the given channel.
- Ritorna:
The string of the mentioned channel.
- Tipo di ritorno:
- property voice_states: List[VoiceState]#
Nuovo nella versione 4.4.0.
Returns all voice states this channel has. Only applicable for voice channels.
- Tipo di ritorno:
List[VoiceState]
- history(start_at=<interactions.MISSING>, reverse=False, maximum=inf, check=None)[sorgente]#
Nuovo nella versione 4.3.2.
- Parametri:
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
- Ritorna:
An asynchronous iterator over the history of the channel
- Tipo di ritorno:
- 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>)[sorgente]#
Nuovo nella versione 4.0.2.
Sends a message in the channel.
- Parametri:
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]]]) –
Nuovo nella versione 4.2.0.
A file or list of files to be attached to the message.
attachments (Optional[List[Attachment]]) –
Nuovo nella versione 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]]) –
Nuovo nella versione 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.
- Ritorna:
The sent message as an object.
- Tipo di ritorno:
- async delete()[sorgente]#
Nuovo nella versione 4.0.2.
Deletes the channel.
- 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)[sorgente]#
Nuovo nella versione 4.0.2.
Edits the channel.
Nuovo nella versione 4.2.0: The fields
archived,auto_archive_durationandlocked. All require the provided channel to be a thread.- Parametri:
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]) –
Nuovo nella versione 4.2.0.
Whether the thread is archived
auto_archive_duration (Optional[int]) –
Nuovo nella versione 4.2.0.
The time after the thread is automatically archived. One of 60, 1440, 4320, 10080
locked (Optional[bool]) –
Nuovo nella versione 4.2.0.
Whether the thread is locked
reason (Optional[str]) – The reason for the edit
- Ritorna:
The modified channel as new object
- Tipo di ritorno:
- async set_name(name, *, reason=None)[sorgente]#
Nuovo nella versione 4.1.0.
Sets the name of the channel.
- async set_topic(topic, *, reason=None)[sorgente]#
Nuovo nella versione 4.1.0.
Sets the topic of the channel.
- async set_bitrate(bitrate, *, reason=None)[sorgente]#
Nuovo nella versione 4.1.0.
Sets the bitrate of the channel.
- async set_user_limit(user_limit, *, reason=None)[sorgente]#
Nuovo nella versione 4.1.0.
Sets the user_limit of the channel.
- async set_rate_limit_per_user(rate_limit_per_user, *, reason=None)[sorgente]#
Nuovo nella versione 4.1.0.
Sets the amount of seconds a user has to wait before sending another message.
- async set_position(position, *, reason=None)[sorgente]#
Nuovo nella versione 4.1.0.
Sets the position of the channel.
- async set_parent_id(parent_id, *, reason=None)[sorgente]#
Nuovo nella versione 4.1.0.
Sets the parent_id of the channel.
- async set_nsfw(nsfw, *, reason=None)[sorgente]#
Nuovo nella versione 4.1.0.
Sets the nsfw-flag of the channel.
- async archive(archived=True, *, reason=None)[sorgente]#
Nuovo nella versione 4.2.0.
Sets the archived state of the thread.
- async set_auto_archive_duration(auto_archive_duration, *, reason=None)[sorgente]#
Nuovo nella versione 4.2.0.
Sets the time after the thread is automatically archived.
- async lock(locked=True, *, reason=None)[sorgente]#
Nuovo nella versione 4.2.0.
Sets the locked state of the thread.
- async add_member(member_id)[sorgente]#
Nuovo nella versione 4.2.0.
This adds a member to the channel, if the channel is a thread.
- Parametri:
member_id (int) – The id of the member to add to the channel
- async remove_member(member_id)[sorgente]#
Nuovo nella versione 4.3.0.
This removes a member of the channel, if the channel is a thread.
- Parametri:
member_id (int) – The id of the member to remove of the channel
- async pin_message(message_id)[sorgente]#
Nuovo nella versione 4.0.2.
Pins a message to the channel.
- async unpin_message(message_id)[sorgente]#
Nuovo nella versione 4.0.2.
Unpins a message from the channel.
- async publish_message(message_id)[sorgente]#
Nuovo nella versione 4.0.2.
Publishes (API calls it crossposts) a message in the channel to any that is followed by.
- async get_pinned_messages()[sorgente]#
Nuovo nella versione 4.0.2.
Get all pinned messages from the channel.
- Ritorna:
A list of pinned message objects.
- Tipo di ritorno:
List[Message]
- async get_message(message_id)[sorgente]#
Nuovo nella versione 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)[sorgente]#
Nuovo nella versione 4.1.0.
Purges a given amount of messages from a channel. You can specify a check function to exclude specific messages.
Avvertimento
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
- Parametri:
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
Cambiato nella versione 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]) –
Nuovo nella versione 4.4.0: Whether to stop deleting messages when the 14 days bulk limit was hit, default
False
- Ritorna:
A list of the deleted messages
- Tipo di ritorno:
List[Message]
- async create_thread(name, type=ChannelType.PUBLIC_THREAD, auto_archive_duration=<interactions.MISSING>, invitable=<interactions.MISSING>, message_id=<interactions.MISSING>, reason=None)[sorgente]#
Nuovo nella versione 4.1.0.
Creates a thread in the Channel.
- Parametri:
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
- Ritorna:
The created thread
- Tipo di ritorno:
- 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)[sorgente]#
Creates an invite for the channel
- Parametri:
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 di ritorno:
- async get_history(limit=100)[sorgente]#
Nuovo nella versione 4.2.0.
Deprecato dalla versione 4.3.2: Use the
history()method insteadGets messages from the channel’s history.
- async get_webhooks()[sorgente]#
Nuovo nella versione 4.3.0.
Gets a list of webhooks of that channel
- async get_members()[sorgente]#
Nuovo nella versione 4.3.0.
Gets the list of thread members
- Ritorna:
The members of the thread.
- Tipo di ritorno:
List[ThreadMember]
- async leave()[sorgente]#
Nuovo nella versione 4.3.0.
Removes the bot from the thread
- async join()[sorgente]#
Nuovo nella versione 4.3.0.
Add the bot to the thread
- async create_tag(name, emoji_id=<interactions.MISSING>, emoji_name=<interactions.MISSING>)[sorgente]#
Nuovo nella versione 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>)[sorgente]#
Nuovo nella versione 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.
- Parametri:
- Ritorna:
The modified tag
- Tipo di ritorno:
- async delete_tag(tag_id)[sorgente]#
Nuovo nella versione 4.3.2.
Deletes a tag
- 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)[sorgente]#
Nuovo nella versione 4.3.2.
Creates a new post inside a forum channel
- Parametri:
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
- Ritorna:
A channel of type
ChannelType.PUBLIC_THREAD- Tipo di ritorno:
- async get_permissions_for(member)[sorgente]#
Nuovo nella versione 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().- Parametri:
member (Member) – The member to get the permissions from
- Ritorna:
Permissions of the member in this channel
- Tipo di ritorno:
- async add_permission_overwrite(id, type=<interactions.MISSING>, allow=<interactions.MISSING>, deny=<interactions.MISSING>, reason=None)[sorgente]#
Nuovo nella versione 4.4.0.
Adds a permission overwrite to the channel.
- Parametri:
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
- Ritorna:
The updated channel
- Tipo di ritorno:
- async add_permission_overwrites(overwrites, reason=None)[sorgente]#
Nuovo nella versione 4.4.0.
Add multiple overwrites to the channel.
- async overwrite_permission_overwrites(overwrites, reason=None)[sorgente]#
Nuovo nella versione 4.4.0.
Overwrites the overwrites of the channel with new overwrites.
- async remove_permission_overwrite_for(id, reason=None)[sorgente]#
Nuovo nella versione 4.4.0.
Removes the overwrite for the given ID.
- class interactions.api.models.channel.ThreadMember(kwargs_dict=None, /, **other_kwargs)[sorgente]#
A class object representing a member in a thread.
Nota
idonly shows if there are active intents involved with the member in the thread.- Variabili:
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)[sorgente]#
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.- Variabili:
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)[sorgente]#
Nuovo nella versione 4.3.2.
A class object that allows iterating through a channel’s history.
- Parametri:
_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
- async flatten()[sorgente]#
Returns all remaining items as list
- class interactions.api.models.channel.AsyncTypingContextManager(obj, _client)[sorgente]#
Nuovo nella versione 4.3.2.
An async context manager for triggering typing.
- class interactions.api.models.channel.Tags(kwargs_dict=None, /, **other_kwargs)[sorgente]#
Nuovo nella versione 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.
- Variabili:
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 delete(channel_id)[sorgente]#
Deletes this tag
- async edit(channel_id, name, emoji_name=<interactions.MISSING>, emoji_id=<interactions.MISSING>)[sorgente]#
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.
- Parametri:
- Ritorna:
The modified tag
- Tipo di ritorno: