hikari.channels#
Application and entities that are used to describe both DMs and guild channels on Discord.
WebhookChannelT module-attribute #
WebhookChannelT = typing.Union[
GuildTextChannel, GuildNewsChannel
]
Union of the channel types which incoming and follower webhooks can be attached to.
The following types are in this:
WebhookChannelTypes module-attribute #
WebhookChannelTypes: tuple[
type[GuildTextChannel], type[GuildNewsChannel]
] = (GuildTextChannel, GuildNewsChannel)
Tuple of the channel types which are valid for hikari.channels.WebhookChannelT.
This includes:
ChannelFlag #
Bases: Flag
The flags for a channel.
CHANNEL_OBFUSCATED class-attribute instance-attribute #
CHANNEL_OBFUSCATED = 1 << 17
The channel's metadata has been obfuscated because the current user cannot view it.
Obfuscated channels have their sensitive fields nulled, reduced or replaced with placeholder values (e.g. the channel's name becomes "___hidden___") and their permission overwrites will contain a single overwrite denying hikari.permissions.Permissions.VIEW_CHANNEL for the guild's @everyone role. The channel's ID, type, position and parent ID are never obfuscated.
This flag is the only reliable way to detect whether a channel has been obfuscated and is only ever set on channels received over the gateway; the REST API omits obfuscated channels entirely instead.
Note
Until November 16, 2026, channels are only obfuscated if the application has opted into the hikari.capabilities.GatewayCapabilities.CHANNEL_OBFUSCATION capability or through the Private Channel Obfuscation developer portal toggle. After that, obfuscation will apply to all applications automatically.
PINNED class-attribute instance-attribute #
PINNED = 1 << 1
The thread is pinned in a forum channel.
Note
As of writing, this can only be set for threads belonging to a forum channel.
REQUIRE_TAG class-attribute instance-attribute #
REQUIRE_TAG = 1 << 4
Whether a tag is required to be specified when creating a thread in a forum channel
Note
As of writing, this can only be set for forum channels.
ChannelFollow #
Relationship between a news channel and a subscriber channel.
The subscriber channel will receive crosspost messages that correspond to any "broadcast" announcements that the news channel creates.
app class-attribute instance-attribute #
app: RESTAware = attrs.field(
repr=False,
eq=False,
hash=False,
metadata={attrs_extensions.SKIP_DEEP_COPY: True},
)
Client application that models may use for procedures.
channel_id class-attribute instance-attribute #
Return the channel ID of the channel being followed.
webhook_id class-attribute instance-attribute #
Return the ID of the webhook for this follow.
fetch_channel async #
fetch_channel() -> GuildNewsChannel | GuildTextChannel
Fetch the object of the guild channel being followed.
| RETURNS | DESCRIPTION |
|---|---|
Union[GuildNewsChannel, GuildTextChannel] | The channel being followed. While this will usually be |
| RAISES | DESCRIPTION |
|---|---|
UnauthorizedError | If you are unauthorized to make the request (invalid/missing token). |
ForbiddenError | If you are missing the |
NotFoundError | If the channel is not found. |
RateLimitTooLongError | Raised in the event that a rate limit occurs that is longer than |
InternalServerError | If an internal error occurs on Discord while handling the request. |
fetch_webhook async #
fetch_webhook() -> ChannelFollowerWebhook
Fetch the webhook attached to this follow.
| RETURNS | DESCRIPTION |
|---|---|
ChannelFollowerWebhook | The webhook attached to this follow. |
| RAISES | DESCRIPTION |
|---|---|
ForbiddenError | If you are missing the |
UnauthorizedError | If you are unauthorized to make the request (invalid/missing token). |
NotFoundError | If the webhook is not found. |
RateLimitTooLongError | Raised in the event that a rate limit occurs that is longer than |
InternalServerError | If an internal error occurs on Discord while handling the request. |
get_channel #
get_channel() -> GuildNewsChannel | GuildTextChannel | None
Get the channel being followed from the cache.
Warning
This will always be None if you are not in the guild that this channel exists in.
| RETURNS | DESCRIPTION |
|---|---|
Union[GuildNewsChannel, GuildTextChannel, None] | The object of the guild channel that was found in the cache or |
ChannelType #
Bases: int, Enum
The known channel types that are exposed to us by the API.
GUILD_CATEGORY class-attribute instance-attribute #
GUILD_CATEGORY = 4
An category used for organizing channels in a guild.
GUILD_FORUM class-attribute instance-attribute #
GUILD_FORUM = 15
A channel consisting of a collection of public guild threads.
GUILD_MEDIA class-attribute instance-attribute #
GUILD_MEDIA = 16
A channel of threads, quite similar to GUILD_FORUM, for media.
GUILD_NEWS class-attribute instance-attribute #
GUILD_NEWS = 5
A channel that can be followed and can crosspost.
GUILD_NEWS_THREAD class-attribute instance-attribute #
GUILD_NEWS_THREAD = 10
A temporary sub-channel within a hikari.channels.ChannelType.GUILD_NEWS channel.
GUILD_PRIVATE_THREAD class-attribute instance-attribute #
GUILD_PRIVATE_THREAD = 12
A temporary sub-channel with restricted access.
Like hikari.channels.ChannelType.GUILD_PUBLIC_THREAD, these exist within hikari.channels.ChannelType.GUILD_TEXT channels but can only be accessed by members who are invited to them or have hikari.permissions.Permissions.MANAGE_THREADS permission.
GUILD_PUBLIC_THREAD class-attribute instance-attribute #
GUILD_PUBLIC_THREAD = 11
A temporary sub-channel within a hikari.channels.ChannelType.GUILD_TEXT channel.
GUILD_STAGE class-attribute instance-attribute #
GUILD_STAGE = 13
A few to many voice channel for hosting events.
DMChannel #
Bases: PrivateChannel, TextableChannel
Represents a direct message text channel that is between you and another user.
ForumLayoutType #
ForumSortOrderType #
ForumTag #
Bases: Unique
Represents a forum tag.
id class-attribute instance-attribute #
id: Snowflake = attrs.field(
eq=True,
hash=True,
repr=True,
converter=snowflakes.Snowflake,
factory=snowflakes.Snowflake.min,
)
The ID of the tag.
When creating tags, this will be 0.
moderated class-attribute instance-attribute #
The whether this flag can only be applied by moderators.
Moderators are those with hikari.permissions.Permissions.MANAGE_CHANNELS or hikari.permissions.Permissions.ADMINISTRATOR permissions.
name class-attribute instance-attribute #
The name of the tag.
GroupDMChannel #
Bases: PrivateChannel
Represents a group direct message channel.
Note
This doesn't have the methods found on hikari.channels.TextableChannel as bots cannot interact with a group DM that they own by sending or seeing messages in it.
application_id class-attribute instance-attribute #
The ID of the application that created the group DM.
If the group DM was not created by a bot, this will be None.
icon_hash class-attribute instance-attribute #
The CDN hash of the icon of the group, if an icon is set.
nicknames class-attribute instance-attribute #
nicknames: MutableMapping[Snowflake, str] = attrs.field(
eq=False, hash=False, repr=False
)
A mapping of set nicknames within this group DMs to user IDs.
owner_id class-attribute instance-attribute #
The ID of the owner of the group.
recipients class-attribute instance-attribute #
The recipients of the group DM.
make_icon_url #
make_icon_url(
*,
file_format: Literal[
"PNG", "JPEG", "JPG", "WEBP"
] = "PNG",
size: int = 4096,
lossless: bool = True,
) -> URL | None
Generate the icon URL for this group, if set.
| PARAMETER | DESCRIPTION |
|---|---|
file_format | The format to use for this URL. Supports If not specified, the format will be TYPE: |
size | The size to set for the URL; Can be any power of two between TYPE: |
lossless | Whether to return a lossless or compressed WEBP image; This is ignored if TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Optional[URL] | The URL, or |
| RAISES | DESCRIPTION |
|---|---|
TypeError | If an invalid format is passed for |
ValueError | If |
GuildCategory #
Bases: PermissibleGuildChannel
Represents a guild category channel.
These can contain other channels inside, and act as a method for organisation.
GuildChannel #
Bases: PartialChannel
The base for anything that is a guild channel.
application_id class-attribute instance-attribute #
The ID of the application associated with this channel.
This will be None for channels which are not associated with an application.
guild_id class-attribute instance-attribute #
The ID of the guild the channel belongs to.
parent_id class-attribute instance-attribute #
The ID of the parent channel the channel belongs to.
For thread channels this will refer to the parent textable guild channel. For other guild channel types this will refer to the parent category and if no parent category is set for the channel, this will be None. For guild categories this will always be None.
shard_id property #
shard_id: int | None
Return the shard ID for the shard.
This may be None if the shard count is not known.
edit async #
edit(
*,
name: UndefinedOr[str] = UNDEFINED,
position: UndefinedOr[int] = UNDEFINED,
topic: UndefinedOr[str] = UNDEFINED,
nsfw: UndefinedOr[bool] = UNDEFINED,
bitrate: UndefinedOr[int] = UNDEFINED,
video_quality_mode: UndefinedOr[
VideoQualityMode | int
] = UNDEFINED,
user_limit: UndefinedOr[int] = UNDEFINED,
rate_limit_per_user: UndefinedOr[
Intervalish
] = UNDEFINED,
region: UndefinedOr[VoiceRegion | str] = UNDEFINED,
permission_overwrites: UndefinedOr[
Sequence[PermissionOverwrite]
] = UNDEFINED,
parent_category: UndefinedOr[
SnowflakeishOr[GuildCategory]
] = UNDEFINED,
default_auto_archive_duration: UndefinedOr[
Intervalish
] = UNDEFINED,
flags: UndefinedOr[ChannelFlag] = UNDEFINED,
archived: UndefinedOr[bool] = UNDEFINED,
auto_archive_duration: UndefinedOr[
Intervalish
] = UNDEFINED,
locked: UndefinedOr[bool] = UNDEFINED,
invitable: UndefinedOr[bool] = UNDEFINED,
applied_tags: UndefinedOr[
SnowflakeishSequence[ForumTag]
] = UNDEFINED,
reason: UndefinedOr[str] = UNDEFINED,
) -> PartialChannel
Edit the text channel.
| PARAMETER | DESCRIPTION |
|---|---|
name | If provided, the new name for the channel. TYPE: |
position | If provided, the new position for the channel. TYPE: |
topic | If provided, the new topic for the channel. TYPE: |
nsfw | If provided, whether the channel should be marked as NSFW or not. TYPE: |
bitrate | If provided, the new bitrate for the channel. TYPE: |
video_quality_mode | If provided, the new video quality mode for the channel. TYPE: |
user_limit | If provided, the new user limit in the channel. TYPE: |
rate_limit_per_user | If provided, the new rate limit per user in the channel. TYPE: |
region | If provided, the voice region to set for this channel. Passing TYPE: |
permission_overwrites | If provided, the new permission overwrites for the channel. TYPE: |
parent_category | If provided, the new guild category for the channel. TYPE: |
default_auto_archive_duration | If provided, the auto archive duration Discord's end user client should default to when creating threads in this channel. This should be either 60, 1440, 4320 or 10080 minutes, as of writing. TYPE: |
flags | If provided, the new channel flags to use for the channel. This can only be used on a forum channel to apply ChannelFlag.REQUIRE_TAG, or on a forum thread to apply ChannelFlag.PINNED. TYPE: |
archived | If provided, the new archived state for the thread. This only applies to threads. TYPE: |
auto_archive_duration | If provided, the new auto archive duration for this thread. This only applies to threads. This should be either 60, 1440, 4320 or 10080 minutes, as of writing. TYPE: |
locked | If provided, the new locked state for the thread. This only applies to threads. If it's locked then only people with TYPE: |
invitable | If provided, the new setting for whether non-moderators can invite new members to a private thread. This only applies to threads. TYPE: |
applied_tags | If provided, the new tags to apply to the thread. This only applies to threads in a forum channel. TYPE: |
reason | If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
PartialChannel | The edited channel. |
| RAISES | DESCRIPTION |
|---|---|
BadRequestError | If any of the fields that are passed have an invalid value. |
UnauthorizedError | If you are unauthorized to make the request (invalid/missing token). |
ForbiddenError | If you are missing permissions to edit the channel. |
NotFoundError | If the channel is not found. |
RateLimitTooLongError | Raised in the event that a rate limit occurs that is longer than |
InternalServerError | If an internal error occurs on Discord while handling the request. |
fetch_guild async #
fetch_guild() -> PartialGuild
Fetch the guild linked to this channel.
| RETURNS | DESCRIPTION |
|---|---|
RESTGuild | The requested guild. |
| RAISES | DESCRIPTION |
|---|---|
ForbiddenError | If you are not part of the guild. |
NotFoundError | If the guild is not found. |
UnauthorizedError | If you are unauthorized to make the request (invalid/missing token). |
RateLimitTooLongError | Raised in the event that a rate limit occurs that is longer than |
InternalServerError | If an internal error occurs on Discord while handling the request. |
get_guild #
get_guild() -> GatewayGuild | None
GuildForumChannel #
Bases: PermissibleGuildChannel
Represents a guild forum channel.
available_tags class-attribute instance-attribute #
The available tags to select from when creating a thread.
default_auto_archive_duration class-attribute instance-attribute #
The auto archive duration Discord's client defaults to for threads in this channel.
This may be be either 1 hour, 1 day, 3 days or 1 week.
default_layout class-attribute instance-attribute #
default_layout: ForumLayoutType = attrs.field(
eq=False, hash=False, repr=False
)
The default layout for the forum.
default_reaction_emoji_id class-attribute instance-attribute #
The ID of the default reaction emoji.
default_reaction_emoji_name class-attribute instance-attribute #
default_reaction_emoji_name: str | UnicodeEmoji | None = (
attrs.field(eq=False, hash=False, repr=False)
)
Name of the default reaction emoji.
Either the string name of the custom emoji, the object of the hikari.emojis.UnicodeEmoji or None when the relevant custom emoji's data is not available (e.g. the emoji has been deleted).
default_sort_order class-attribute instance-attribute #
default_sort_order: ForumSortOrderType = attrs.field(
eq=False, hash=False, repr=False
)
The default sort order for the forum.
default_thread_rate_limit_per_user class-attribute instance-attribute #
The default delay (in seconds) between a user can send a message in created threads.
If there is no rate limit, this will be 0 seconds.
Note
Any user that has permissions allowing hikari.permissions.Permissions.MANAGE_MESSAGES, hikari.permissions.Permissions.MANAGE_CHANNELS, hikari.permissions.Permissions.ADMINISTRATOR will not be limited. Likewise, bots will not be affected by this rate limit.
last_thread_id class-attribute instance-attribute #
The ID of the last thread created in this channel.
Warning
This might point to an invalid or deleted message. Do not assume that this will always be valid.
rate_limit_per_user class-attribute instance-attribute #
The delay (in seconds) between a user can create threads in this channel.
If there is no rate limit, this will be 0 seconds.
Note
Any user that has permissions allowing hikari.permissions.Permissions.MANAGE_MESSAGES, hikari.permissions.Permissions.MANAGE_CHANNELS, hikari.permissions.Permissions.ADMINISTRATOR will not be limited. Likewise, bots will not be affected by this rate limit.
GuildMediaChannel #
Bases: PermissibleGuildChannel
Represents a guild media channel.
available_tags class-attribute instance-attribute #
The available tags to select from when creating a thread.
default_auto_archive_duration class-attribute instance-attribute #
The auto archive duration Discord's client defaults to for threads in this channel.
This may be be either 1 hour, 1 day, 3 days or 1 week.
default_layout class-attribute instance-attribute #
default_layout: ForumLayoutType = attrs.field(
eq=False, hash=False, repr=False
)
The default layout of a thread-only channel.
default_reaction_emoji_id class-attribute instance-attribute #
The ID of the default reaction emoji.
default_reaction_emoji_name class-attribute instance-attribute #
default_reaction_emoji_name: str | UnicodeEmoji | None = (
attrs.field(eq=False, hash=False, repr=False)
)
Name of the default reaction emoji.
Either the string name of the custom emoji, the object of the hikari.emojis.UnicodeEmoji or None when the relevant custom emoji's data is not available (e.g. the emoji has been deleted).
default_sort_order class-attribute instance-attribute #
default_sort_order: ForumSortOrderType = attrs.field(
eq=False, hash=False, repr=False
)
The default sort order for the forum.
default_thread_rate_limit_per_user class-attribute instance-attribute #
The default delay (in seconds) between a user can send a message in created threads.
If there is no rate limit, this will be 0 seconds.
.. note:: Any user that has permissions allowing MANAGE_MESSAGES, MANAGE_CHANNEL, ADMINISTRATOR will not be limited. Likewise, bots will not be affected by this rate limit.
last_thread_id class-attribute instance-attribute #
The ID of the last thread created in this channel.
.. warning:: This might point to an invalid or deleted message. Do not assume that this will always be valid.
rate_limit_per_user class-attribute instance-attribute #
The delay (in seconds) between a user can create threads in this channel.
If there is no rate limit, this will be 0 seconds.
.. note:: Any user that has permissions allowing MANAGE_MESSAGES, MANAGE_CHANNEL, ADMINISTRATOR will not be limited. Likewise, bots will not be affected by this rate limit.
GuildNewsChannel #
Bases: PermissibleGuildChannel, TextableGuildChannel
Represents an news channel.
default_auto_archive_duration class-attribute instance-attribute #
The auto archive duration Discord's client defaults to for threads in this channel.
This may be be either 1 hour, 1 day, 3 days or 1 week.
last_message_id class-attribute instance-attribute #
The ID of the last message sent in this channel.
Warning
This might point to an invalid or deleted message. Do not assume that this will always be valid.
GuildNewsThread #
GuildPrivateThread #
Bases: GuildThreadChannel
Represents a guild private thread.
GuildPublicThread #
Bases: GuildThreadChannel
Represents a non-news guild channel public thread.
applied_tag_ids class-attribute instance-attribute #
The IDs of the applied tags on this thread.
This will only apply to threads created inside a forum channel.
flags class-attribute instance-attribute #
flags: ChannelFlag = attrs.field(
eq=False, hash=False, repr=False
)
The channel flags for this thread.
This will only apply to threads created inside a forum channel.
Note
As of writing, the only flag that can be set is hikari.channels.ChannelFlag.PINNED.
GuildStageChannel #
Bases: PermissibleGuildChannel, TextableGuildChannel
Represents a stage channel.
bitrate class-attribute instance-attribute #
The bitrate for the stage channel (in bits per second).
last_message_id class-attribute instance-attribute #
The ID of the last message sent in this channel.
Warning
This might point to an invalid or deleted message. Do not assume that this will always be valid.
region class-attribute instance-attribute #
ID of the voice region for this stage channel.
If set to None then this is set to "auto" mode where the used region will be decided based on the first person who connects to it when it's empty.
user_limit class-attribute instance-attribute #
The user limit for the stage channel.
If this is 0, then assume no limit.
video_quality_mode class-attribute instance-attribute #
video_quality_mode: VideoQualityMode | int = attrs.field(
eq=False, hash=False, repr=False
)
The video quality mode for this channel.
GuildTextChannel #
Bases: PermissibleGuildChannel, TextableGuildChannel
Represents a guild text channel.
default_auto_archive_duration class-attribute instance-attribute #
The auto archive duration Discord's client defaults to for threads in this channel.
This may be be either 1 hour, 1 day, 3 days or 1 week.
last_message_id class-attribute instance-attribute #
The ID of the last message sent in this channel.
Warning
This might point to an invalid or deleted message. Do not assume that this will always be valid.
last_pin_timestamp class-attribute instance-attribute #
The timestamp of the last-pinned message.
Note
This may be None in several cases; Discord does not document what these cases are. Trust no one!
rate_limit_per_user class-attribute instance-attribute #
The delay (in seconds) between a user can send a message to this channel.
If there is no rate limit, this will be 0 seconds.
Note
Any user that has permissions allowing hikari.permissions.Permissions.MANAGE_MESSAGES, hikari.permissions.Permissions.MANAGE_CHANNELS, hikari.permissions.Permissions.ADMINISTRATOR will not be limited. Likewise, bots will not be affected by this rate limit.
GuildThreadChannel #
Bases: TextableGuildChannel
Base class for all guild thread channels.
approximate_member_count class-attribute instance-attribute #
Approximate count of members in the thread channel.
Warning
This stop counting at 50.
approximate_message_count class-attribute instance-attribute #
Approximate number of messages in the thread channel.
Warning
This stops counting at 50 for threads created before 2022/06/01.
archive_timestamp property #
archive_timestamp: datetime
When the thread's archived state was last changed.
Note
If the thread has never been archived then this will be the thread's creation date and this will be changed when a thread is unarchived.
auto_archive_duration property #
auto_archive_duration: timedelta
How long the thread will be left inactive before being automatically archived.
As of writing this may either 1 hour, 1 day, 3 days or 1 week.
is_locked property #
is_locked: bool
Whether the thread is locked.
When a thread is locked, only users with hikari.permissions.Permissions.MANAGE_THREADS permission can un-archive it.
last_message_id class-attribute instance-attribute #
The ID of the last message sent in this channel.
Warning
This might point to an invalid or deleted message. Do not assume that this will always be valid.
last_pin_timestamp class-attribute instance-attribute #
The timestamp of the last-pinned message.
Note
This may be None in several cases; Discord does not document what these cases are. Trust no one!
member class-attribute instance-attribute #
member: ThreadMember | None = attrs.field(
eq=False, hash=False, repr=True
)
Thread member object for the current user, if they are in the thread.
Note
This is only returned by some endpoints and on private thread access events.
metadata class-attribute instance-attribute #
metadata: ThreadMetadata = attrs.field(
eq=False, hash=False, repr=False
)
This threads metadata.
owner_id class-attribute instance-attribute #
ID of the user who created this thread.
parent_id class-attribute instance-attribute #
Id of this thread's textable parent channel.
rate_limit_per_user class-attribute instance-attribute #
The delay (in seconds) between a user can send a message to this channel.
If there is no rate limit, this will be 0 seconds.
Note
Any user that has permissions allowing hikari.permissions.Permissions.MANAGE_MESSAGES, hikari.permissions.Permissions.MANAGE_CHANNELS, hikari.permissions.Permissions.ADMINISTRATOR will not be limited. Likewise, bots will not be affected by this rate limit.
GuildVoiceChannel #
Bases: PermissibleGuildChannel, TextableGuildChannel
Represents a voice channel.
bitrate class-attribute instance-attribute #
The bitrate for the voice channel (in bits per second).
last_message_id class-attribute instance-attribute #
The ID of the last message sent in this channel.
Warning
This might point to an invalid or deleted message. Do not assume that this will always be valid.
region class-attribute instance-attribute #
ID of the voice region for this voice channel.
If set to None then this is set to "auto" mode where the used region will be decided based on the first person who connects to it when it's empty.
user_limit class-attribute instance-attribute #
The user limit for the voice channel.
If this is 0, then assume no limit.
video_quality_mode class-attribute instance-attribute #
video_quality_mode: VideoQualityMode | int = attrs.field(
eq=False, hash=False, repr=False
)
The video quality mode for this channel.
PartialChannel #
Bases: Unique
Channel representation for cases where further detail is not provided.
This is commonly received in HTTP API responses where full information is not available from Discord.
app class-attribute instance-attribute #
app: RESTAware = attrs.field(
repr=False,
eq=False,
hash=False,
metadata={attrs_extensions.SKIP_DEEP_COPY: True},
)
Client application that models may use for procedures.
id class-attribute instance-attribute #
The ID of this entity.
mention property #
mention: str
Return a raw mention string for the channel.
Note
There are platform specific inconsistencies with mentions of GuildCategories, GroupDMChannels and DMChannels showing the correct name but not being interactable.
| RETURNS | DESCRIPTION |
|---|---|
str | The mention string to use. |
name class-attribute instance-attribute #
The channel's name. This will be missing for DM channels.
type class-attribute instance-attribute #
type: ChannelType | int = attrs.field(
eq=False, hash=False, repr=True
)
The channel's type.
delete async #
delete() -> PartialChannel
Delete a channel in a guild, or close a DM.
Note
For Public servers, the set 'Rules' or 'Guidelines' channels and the 'Public Server Updates' channel cannot be deleted.
| RETURNS | DESCRIPTION |
|---|---|
PartialChannel | Object of the channel that was deleted. |
| RAISES | DESCRIPTION |
|---|---|
UnauthorizedError | If you are unauthorized to make the request (invalid/missing token). |
ForbiddenError | If you are missing the |
NotFoundError | If the channel is not found. |
RateLimitTooLongError | Raised in the event that a rate limit occurs that is longer than |
InternalServerError | If an internal error occurs on Discord while handling the request. |
PermissibleGuildChannel #
Bases: GuildChannel
Base class for all guild channels which have permission overwrites.
Note
This doesn't apply to thread channels as they implicitly inherit permissions from their parent channel.
flags class-attribute instance-attribute #
flags: ChannelFlag = attrs.field(
eq=False, hash=False, repr=False
)
The channel flags for this channel.
If hikari.channels.ChannelFlag.CHANNEL_OBFUSCATED is set then this channel's metadata has been obfuscated because the application cannot view it.
is_nsfw class-attribute instance-attribute #
Whether the channel is marked as NSFW.
permission_overwrites class-attribute instance-attribute #
permission_overwrites: Mapping[
Snowflake, PermissionOverwrite
] = attrs.field(eq=False, hash=False, repr=False)
The permission overwrites for the channel.
This maps the ID of the entity in the overwrite to the overwrite data.
position class-attribute instance-attribute #
The sorting position of the channel.
Higher numbers appear further down the channel list.
edit_overwrite async #
edit_overwrite(
target: Snowflakeish
| PartialUser
| PartialRole
| PermissionOverwrite,
*,
target_type: UndefinedOr[
PermissionOverwriteType | int
] = UNDEFINED,
allow: UndefinedOr[Permissions] = UNDEFINED,
deny: UndefinedOr[Permissions] = UNDEFINED,
reason: UndefinedOr[str] = UNDEFINED,
) -> None
Edit permissions for a specific entity in the given guild channel.
This creates new overwrite for the channel, if there no other overwrites present.
| PARAMETER | DESCRIPTION |
|---|---|
target | The channel overwrite to edit. This may be the object or the ID of an existing overwrite. TYPE: |
target_type | If provided, the type of the target to update. If unset, will attempt to get the type from TYPE: |
allow | If provided, the new value of all allowed permissions. TYPE: |
deny | If provided, the new value of all disallowed permissions. TYPE: |
reason | If provided, the reason that will be recorded in the audit logs. Maximum of 512 characters. TYPE: |
| RAISES | DESCRIPTION |
|---|---|
TypeError | If |
BadRequestError | If any of the fields that are passed have an invalid value. |
UnauthorizedError | If you are unauthorized to make the request (invalid/missing token). |
ForbiddenError | If you are missing the |
NotFoundError | If the channel is not found or the target is not found if it is a role. |
RateLimitTooLongError | Raised in the event that a rate limit occurs that is longer than |
InternalServerError | If an internal error occurs on Discord while handling the request. |
remove_overwrite async #
remove_overwrite(
target: PermissionOverwrite
| PartialRole
| PartialUser
| Snowflakeish,
) -> None
Delete a custom permission for an entity in a given guild channel.
| PARAMETER | DESCRIPTION |
|---|---|
target | The channel overwrite to delete. TYPE: |
| RAISES | DESCRIPTION |
|---|---|
UnauthorizedError | If you are unauthorized to make the request (invalid/missing token). |
ForbiddenError | If you are missing the |
NotFoundError | If the channel is not found or the target is not found. |
RateLimitTooLongError | Raised in the event that a rate limit occurs that is longer than |
InternalServerError | If an internal error occurs on Discord while handling the request. |
PermissionOverwrite #
Bases: Unique
Represents permission overwrites for a channel or role in a channel.
You may sometimes need to make instances of this object to add/edit permission overwrites on channels.
Examples:
Creating a permission overwrite.
overwrite = PermissionOverwrite(
id=163979124820541440,
type=PermissionOverwriteType.MEMBER,
allow=(
Permissions.VIEW_CHANNEL
| Permissions.READ_MESSAGE_HISTORY
| Permissions.SEND_MESSAGES
),
deny=(Permissions.MANAGE_MESSAGES | Permissions.SPEAK),
)
allow class-attribute instance-attribute #
allow: Permissions = attrs.field(
converter=permissions.Permissions,
default=permissions.Permissions.NONE,
repr=True,
)
The permissions this overwrite allows.
deny class-attribute instance-attribute #
deny: Permissions = attrs.field(
converter=permissions.Permissions,
default=permissions.Permissions.NONE,
repr=True,
)
The permissions this overwrite denies.
id class-attribute instance-attribute #
id: Snowflake = attrs.field(
converter=snowflakes.Snowflake, repr=True
)
The ID of this entity.
type class-attribute instance-attribute #
type: PermissionOverwriteType | int = attrs.field(
converter=PermissionOverwriteType, repr=True
)
The type of entity this overwrite targets.
unset property #
unset: Permissions
Bitfield of all permissions not explicitly allowed or denied by this overwrite.
PrivateChannel #
Bases: PartialChannel
The base for anything that is a private (non-guild bound) channel.
TextableChannel #
Bases: PartialChannel
Mixin class for a channel which can have text messages in it.
delete_messages async #
delete_messages(
messages: SnowflakeishOr[PartialMessage]
| Iterable[SnowflakeishOr[PartialMessage]]
| AsyncIterable[SnowflakeishOr[PartialMessage]],
/,
*other_messages: SnowflakeishOr[PartialMessage],
) -> None
Bulk-delete messages from the channel.
Note
This API endpoint will only be able to delete 100 messages at a time. For anything more than this, multiple requests will be executed one-after-the-other, since the rate limits for this endpoint do not favour more than one request per bucket.
If one message is left over from chunking per 100 messages, or only one message is passed to this coroutine function, then the logic is expected to defer to delete_message. The implication of this is that the delete_message endpoint is ratelimited by a different bucket with different usage rates.
Warning
This endpoint is not atomic. If an error occurs midway through a bulk delete, you will not be able to revert any changes made up to this point.
Warning
Specifying any messages more than 14 days old will cause the call to fail, potentially with partial completion.
| PARAMETER | DESCRIPTION |
|---|---|
messages | Either the object/ID of an existing message to delete or an iterable (sync or async) of the objects and/or IDs of existing messages to delete. TYPE: |
*other_messages | The objects and/or IDs of other existing messages to delete. TYPE: |
| RAISES | DESCRIPTION |
|---|---|
BulkDeleteError | An error containing the messages successfully deleted, and the messages that were not removed. The |
fetch_history #
fetch_history(
*,
before: UndefinedOr[
SearchableSnowflakeishOr[Unique]
] = UNDEFINED,
after: UndefinedOr[
SearchableSnowflakeishOr[Unique]
] = UNDEFINED,
around: UndefinedOr[
SearchableSnowflakeishOr[Unique]
] = UNDEFINED,
) -> LazyIterator[Message]
Browse the message history for a given text channel.
Note
This call is not a coroutine function, it returns a special type of lazy iterator that will perform API calls as you iterate across it, thus any errors documented below will happen then. See hikari.iterators for the full API for this iterator type.
| PARAMETER | DESCRIPTION |
|---|---|
before | If provided, fetch messages before this snowflakes. If you provide a datetime object, it will be transformed into a snowflakes. This may be any other Discord entity that has an ID. In this case, the date the object was first created will be used. TYPE: |
after | If provided, fetch messages after this snowflakes. If you provide a datetime object, it will be transformed into a snowflakes. This may be any other Discord entity that has an ID. In this case, the date the object was first created will be used. TYPE: |
around | If provided, fetch messages around this snowflakes. If you provide a datetime object, it will be transformed into a snowflakes. This may be any other Discord entity that has an ID. In this case, the date the object was first created will be used. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
LazyIterator[Message] | A iterator to fetch the messages. |
| RAISES | DESCRIPTION |
|---|---|
TypeError | If you specify more than one of |
UnauthorizedError | If you are unauthorized to make the request (invalid/missing token). |
ForbiddenError | If you lack permissions to read message history in the given channel. |
NotFoundError | If the channel is not found. |
InternalServerError | If an internal error occurs on Discord while handling the request. |
fetch_message async #
fetch_message(
message: SnowflakeishOr[PartialMessage],
) -> Message
Fetch a specific message in the given text channel.
| PARAMETER | DESCRIPTION |
|---|---|
message | The message to fetch. This may be the object or the ID of an existing channel. TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Message | The requested message. |
| RAISES | DESCRIPTION |
|---|---|
UnauthorizedError | If you are unauthorized to make the request (invalid/missing token). |
ForbiddenError | If you are missing the |
NotFoundError | If the channel is not found or the message is not found in the given text channel. |
RateLimitTooLongError | Raised in the event that a rate limit occurs that is longer than |
InternalServerError | If an internal error occurs on Discord while handling the request. |
fetch_pins #
fetch_pins() -> LazyIterator[PinnedMessage]
Fetch the pinned messages in this text channel.
| RETURNS | DESCRIPTION |
|---|---|
LazyIterator[PinnedMessage] | The pinned messages in this text channel. |
| RAISES | DESCRIPTION |
|---|---|
UnauthorizedError | If you are unauthorized to make the request (invalid/missing token). |
ForbiddenError | If you are missing the [hikari.permissions.Permissions.VIEW_CHANNEL] permission in the channel. |
NotFoundError | If the channel is not found. |
RateLimitTooLongError | Raised in the event that a rate limit occurs that is longer than |
InternalServerError | If an internal error occurs on Discord while handling the request. |
pin_message async #
pin_message(
message: SnowflakeishOr[PartialMessage],
) -> None
Pin an existing message in the text channel.
| PARAMETER | DESCRIPTION |
|---|---|
message | The message to pin. This may be the object or the ID of an existing message. TYPE: |
| RAISES | DESCRIPTION |
|---|---|
UnauthorizedError | If you are unauthorized to make the request (invalid/missing token). |
ForbiddenError | If you are missing the |
NotFoundError | If the channel is not found, or if the message does not exist in the given channel. |
RateLimitTooLongError | Raised in the event that a rate limit occurs that is longer than |
InternalServerError | If an internal error occurs on Discord while handling the request. |
send async #
send(
content: UndefinedOr[Any] = UNDEFINED,
*,
attachment: UndefinedOr[Resourceish] = UNDEFINED,
attachments: UndefinedOr[
Sequence[Resourceish]
] = UNDEFINED,
component: UndefinedOr[ComponentBuilder] = UNDEFINED,
components: UndefinedOr[
Sequence[ComponentBuilder]
] = UNDEFINED,
embed: UndefinedOr[Embed] = UNDEFINED,
embeds: UndefinedOr[Sequence[Embed]] = UNDEFINED,
sticker: UndefinedOr[
SnowflakeishOr[PartialSticker]
] = UNDEFINED,
stickers: UndefinedOr[
SnowflakeishSequence[PartialSticker]
] = UNDEFINED,
nonce: UndefinedOr[str] = UNDEFINED,
tts: UndefinedOr[bool] = UNDEFINED,
reply: UndefinedOr[
SnowflakeishOr[PartialMessage]
] = UNDEFINED,
reply_must_exist: UndefinedOr[bool] = UNDEFINED,
mentions_everyone: UndefinedOr[bool] = UNDEFINED,
mentions_reply: UndefinedOr[bool] = UNDEFINED,
user_mentions: UndefinedOr[
SnowflakeishSequence[PartialUser] | bool
] = UNDEFINED,
role_mentions: UndefinedOr[
SnowflakeishSequence[PartialRole] | bool
] = UNDEFINED,
flags: UndefinedType | int | MessageFlag = UNDEFINED,
) -> Message
Create a message in this channel.
| PARAMETER | DESCRIPTION |
|---|---|
content | If provided, the message contents. If If this is a Likewise, if this is a TYPE: |
attachment | If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL. Attachments can be passed as many different things, to aid in convenience.
TYPE: |
attachments | If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs. TYPE: |
component | If provided, builder object of the component to include in this message. TYPE: |
components | If provided, a sequence of the component builder objects to include in this message. TYPE: |
embed | If provided, the message embed. TYPE: |
embeds | If provided, the message embeds. TYPE: |
sticker | If provided, the object or ID of a sticker to send on the message. As of writing, bots can only send custom stickers from the current guild. TYPE: |
stickers | If provided, a sequence of the objects and IDs of up to 3 stickers to send on the message. As of writing, bots can only send custom stickers from the current guild. TYPE: |
tts | If provided, whether the message will be TTS (Text To Speech). TYPE: |
nonce | If provided, a nonce that can be used for optimistic message sending. TYPE: |
reply | If provided, the message to reply to. TYPE: |
reply_must_exist | If provided, whether to error if the message being replied to does not exist instead of sending as a normal (non-reply) message. This will not do anything if not being used with TYPE: |
mentions_everyone | If provided, whether the message should parse @everyone/@here mentions. TYPE: |
mentions_reply | If provided, whether to mention the author of the message that is being replied to. This will not do anything if not being used with TYPE: |
user_mentions | If provided, and TYPE: |
role_mentions | If provided, and TYPE: |
flags | If provided, optional flags to set on the message. If Note that some flags may not be able to be set. Currently the only flags that can be set are TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Message | The created message. |
| RAISES | DESCRIPTION |
|---|---|
BadRequestError | This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; |
UnauthorizedError | If you are unauthorized to make the request (invalid/missing token). |
ForbiddenError | If you lack permissions to send messages in the given channel. |
NotFoundError | If the channel is not found. |
InternalServerError | If an internal error occurs on Discord while handling the request. |
ValueError | If more than 100 unique objects/entities are passed for |
TypeError | If both |
trigger_typing #
trigger_typing() -> TypingIndicator
Trigger typing in a given channel.
This returns an object that can either be awaited to trigger typing once, or used as an async context manager to keep typing until the block completes.
await channel.trigger_typing() # type for 10s
async with channel.trigger_typing():
await asyncio.sleep(35) # keep typing until this finishes
Note
Sending a message to this channel will stop the typing indicator. If using an async with, it will start up again after a few seconds. This is a limitation of Discord's API.
| RETURNS | DESCRIPTION |
|---|---|
TypingIndicator | The typing indicator object. |
unpin_message async #
unpin_message(
message: SnowflakeishOr[PartialMessage],
) -> None
Unpin a given message from the text channel.
| PARAMETER | DESCRIPTION |
|---|---|
message | The message to unpin. This may be the object or the ID of an existing message. TYPE: |
| RAISES | DESCRIPTION |
|---|---|
UnauthorizedError | If you are unauthorized to make the request (invalid/missing token). |
ForbiddenError | If you are missing the |
NotFoundError | If the channel is not found or the message is not a pinned message in the given channel. |
RateLimitTooLongError | Raised in the event that a rate limit occurs that is longer than |
InternalServerError | If an internal error occurs on Discord while handling the request. |
TextableGuildChannel #
Bases: GuildChannel, TextableChannel
Mixin class for any guild channel which can have text messages in it.
ThreadMember #
Represents a thread's member.
flags class-attribute instance-attribute #
Bitfield flag of the user's settings for the thread.
Note
As of writing, the values of this field's are undocumented.
joined_at class-attribute instance-attribute #
When the user joined the relevant thread.
thread_id class-attribute instance-attribute #
ID of the thread this member is in.
ThreadMetadata #
Represents a thread's metadata.
archive_timestamp class-attribute instance-attribute #
When the thread's archived state was last changed.
Note
If the thread has never been archived then this will be the thread's creation date and this will be changed when a thread is unarchived.
auto_archive_duration class-attribute instance-attribute #
How long the thread will be left inactive before being automatically archived.
As of writing this may either 1 hour, 1 day, 3 days or 1 week.
created_at class-attribute instance-attribute #
When the thread was created.
Will be None for threads created before 2022-01-09.
is_archived class-attribute instance-attribute #
Whether the thread is archived.
is_invitable class-attribute instance-attribute #
Whether the thread is invitable by non moderators.
This only applies to private threads, otherwise always True.
is_locked class-attribute instance-attribute #
Whether the thread is locked.
When a thread is locked, only users with hikari.permissions.Permissions.MANAGE_THREADS permission can un-archive it.