Skip to content

Channel Resource

Note

The following classes come from the discord.resources.channel module.


Channel dataclass

Bases: DataModel

Represents a Discord guild channel.

id: int instance-attribute

ID of the channel.

guild_id: Optional[int] = None class-attribute instance-attribute

Guild ID of the channel.

parent_id: Optional[int] = None class-attribute instance-attribute

Category ID of the channel.

position: Optional[int] = None class-attribute instance-attribute

Position of the channel.

name: Optional[str] = None class-attribute instance-attribute

Name of the channel.

topic: Optional[str] = None class-attribute instance-attribute

Topic of the channel.

nsfw: Optional[bool] = None class-attribute instance-attribute

If the channel is flagged NSFW.

last_message_id: Optional[int] = None class-attribute instance-attribute

ID of the last message sent in the channel.

last_pin_timestamp: Optional[str] = None class-attribute instance-attribute

ISO8601 timestamp of the last pinned messsage in the channel.

rate_limit_per_user: Optional[int] = None class-attribute instance-attribute

Seconds user must wait between sending messages in the channel.

fetch async

Fetch the full channel data from Discord.

Returns:

  • Channel

    A new Channel object with all fields populated

fetch_messages async

Fetches this channel's messages.

Permissions
  • VIEW_CHANNEL → required to access channel messages
  • READ_MESSAGE_HISTORY → required for user, otherwise no messages are returned

Parameters:

  • **kwargs (Unpack[MessagesFetchParams], default: {} ) –

    field-specific data

    Note

    if no kwargs are provided, default to 50 fetched messages limit.

Returns:

  • list[Message]

    queried messages

send async

Send a message to this channel.

Permissions
  • SEND_MESSAGES → required to create a message in this channel

Parameters:

  • message (str | MessageBuilder) –

    can be just text or the MessageBuilder for dynamic messages

Returns:

  • Message

    The created Message object

edit async

Edit this channel's settings.

Permissions
  • MANAGE_CHANNELS → required to edit this channel

Parameters:

  • channel (GuildChannel) –

    channel changes

Returns:

  • Channel

    The updated channel object

create_thread_from_message async

Create a thread from this message

Parameters:

  • message_id (int) –

    ID of message to attach thread

  • name (str) –

    thread name

Returns:

  • Channel

    The updated channel object

fetch_pins async

Get this channel's pinned messages.

Permissions
  • VIEW_CHANNEL → required to access pinned messages
  • READ_MESSAGE_HISTORY → required for reading pinned messages

Parameters:

  • kwargs (Unpack[PinsFetchParams], default: {} ) –

    field-specific data

    Note

    If no kwargs are provided, default to 50 fetched messages limit.

Returns:

delete async

Deletes this channel from the server.

Permissions
  • MANAGE_CHANNELS → required to delete this channel

PinnedMessage dataclass

Bases: DataModel

Pinned message data.

message: Message instance-attribute

Message resource of the pinned message.

pinned_at: Optional[str] = None class-attribute instance-attribute

ISO8601 timestamp of when the message was pinned.


PinsFetchParams

Bases: TypedDict

Params when fetching pinned messages.

before: str instance-attribute

Get pinned messages before this ISO8601 timestamp.

limit: int instance-attribute

Max number of pinned messages to return. Range 1 - 50. Default 50.


MessagesFetchParams

Bases: TypedDict

Params when fetching guild channel messages.

limit: int instance-attribute

Max number of messages to return. Range 1 - 100. Default 50.

before: int instance-attribute

Get messages before this message ID.

after: int instance-attribute

Get messages after this message ID.

around: int instance-attribute

Get messages around this message ID.