Skip to content

Channel Resource

Note

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


Channel dataclass

Bases: BaseResource

Represents a Discord channel.

id: int instance-attribute

ID of the channel.

context: Any instance-attribute

Associated user data.

fetch async

Fetch the full channel data from Discord.

Returns:

delete async

Deletes this channel from the server. Fires ChannelUpdateEvent if success, and ChannelDeleteEvent (or ThreadDeleteEvent if a thread).

Permissions

Requires MANAGE_CHANNELS and MANAGE_THREADS

follow async

Follow announcement channel to send messages to a target channel. Fires WebhooksUpdateEvent.

Parameters:

  • webhook_channel_id (int) –

    ID of target channel

Returns:

edit_guild_channel async

Edit this channel. Fires ChannelUpdateEvent.

Note

If modifying a category, all child channels also fire ChannelUpdateEvent.

Permissions

Requires MANAGE_CHANNELS

Parameters:

Returns:

fetch_messages async

Fetches this channel's messages.

Permissions

Requires VIEW_CHANNEL and READ_MESSAGE_HISTORY

Parameters:

  • limit (int, default: 50 ) –

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

  • before (int, default: None ) –

    get messages before this message ID

  • after (int, default: None ) –

    get messages after this message ID

  • around (int, default: None ) –

    get messages around this message ID

Returns:

fetch_pins async

Get this channel's pinned messages.

Permissions

Requires VIEW_CHANNEL and READ_MESSAGE_HISTORY

Note

  • Creates a PUBLIC_THREAD when called on a GUILD_TEXT channel
  • Creates an ANNOUNCEMENT_THREAD when called on a GUILD_ANNOUNCEMENT channel

Warning

Does not work on a GUILD_FORUM channel!

Parameters:

  • before (str, default: None ) –

    get pinned messages before this ISO8601 timestamp

  • limit (int, default: 50 ) –

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

Returns:

  • list[PinnedMessage]

    queried list of pinned messages

send async

Send a message to this channel. Fires MessageCreateEvent.

Permissions

Requires SEND_MESSAGES

Parameters:

Returns:

bulk_delete_messages async

Delete multiple messages in a single request. Fires BulkMessageDeleteEvent.

Permissions

Requires MANAGE_MESSAGES.

Important

Messages older than 2 weeks will fail to get deleted!

Note

Only available for GUILD_TEXT channels.

Parameters:

  • message_ids (list[int]) –

    IDs of the messages to delete range(2, 100)

fetch_invites async

Fetch a list of invites for this channel.

Permissions

Requires MANAGE_CHANNELS

Note

Only usable on guild channels.

Returns:

create_invite async

Create a new invite for this channel. Fires InviteCreateEvent.

Permissions

Requires CREATE_INSTANT_INVITE

Parameters:

Returns:

fetch_thread_member async

Fetch a thread emmber of the specified user ID from this thread.

Parameters:

  • user_id (int) –

    ID of the user to fetch

  • with_member (bool, default: False ) –

    whether to include the member object. Defaults to False.

Returns:

fetch_thread_members async

Fetch all members of this thread.

Warning

Requires the GUILD_MEMBERS privileged intent to use!

Parameters:

  • limit (int, default: 100 ) –

    Max number of thread members to return. Range 0 - 100. Defaults to 100.

  • after (int, default: None ) –

    members after this user ID

  • with_member (bool, default: False ) –

    whether to include the member object. Defaults to False.

Returns:

create_thread_from_message async

Create a thread from a message (attached to the message). Fires ThreadCreateEvent and MessageUpdateEvent.

Parameters:

  • message_id (int) –

    ID of the message to attach the thread

  • thread (ThreadFromMessagePart) –

    thread to attach

Returns:

create_thread_without_message async

Create a thread not connected to an existing message. Fires ThreadCreateEvent.

Parameters:

Returns:

edit_thread async

Edit this thread. Fires ChannelUpdateEvent.

Permissions

Requires MANAGE_CHANNELS

Important

Requires archived be False or set to False.

Parameters:

Returns:

join_thread async

Add the bot to this thread. Fires ThreadMembersUpdateEvent and ThreadCreateEvent.

Important

Required the thread NOT be archived.

leave_thread async

Remove the bot from a thread. Fires ThreadMembersUpdateEvent.

Important

Required the thread NOT be archived.

add_thread_member async

Add a user to this thread. Fires ThreadMembersUpdateEvent.

Parameters:

  • user_id (int) –

    ID of the user to add

remove_thread_member async

Remove a user to this thread. Fires ThreadMembersUpdateEvent.

Parameters:

  • user_id (int) –

    ID of the user to remove

fetch_public_archived_threads async

Fetch archived public threads in this channel.

Permissions

Requires READ_MESSAGE_HISTORY

!!! note: Returns PUBLIC_THREAD threads if this is a GUILD_TEXT channel. Returns ANNOUNCEMENT_THREAD if this is a GUILD_ANNOUNCEMENT channel.

Note

Threads are ordered by archive_timestamp in descending order.

Parameters:

  • before (str, default: None ) –

    threads archived before this timestamp

  • limit (int, default: None ) –

    max numer of threads to fetch

Returns:

fetch_private_archived_threads async

Fetch archived private threads in this channel.

Permissions

Requires READ_MESSAGE_HISTORY and MANAGE_THREADS

Note

Threads are ordered by archive_timestamp in descending order.

Parameters:

  • before (str, default: None ) –

    threads archived before this timestamp

  • limit (int, default: None ) –

    max numer of threads to fetch

Returns:

fetch_joined_private_archived_threads async

Fetch archived private threads in this channel the bot has joined.

Permissions

Requires READ_MESSAGE_HISTORY

Note

Threads are ordered by their id in descending order.

Parameters:

  • before (str, default: None ) –

    threads archived before this timestamp

  • limit (int, default: None ) –

    max numer of threads to fetch

Returns: