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
¶
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:
-
FollowedChannelModel–followed channel
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:
-
options(EditGuildChannelParams, default:{}) –channel fields to edit
Returns:
-
ChannelModel–updated channel
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:
-
list[MessageModel]–queried list of messages
fetch_pins
async
¶
Get this channel's pinned messages.
Permissions
Requires VIEW_CHANNEL and READ_MESSAGE_HISTORY
Note
- Creates a
PUBLIC_THREADwhen called on aGUILD_TEXTchannel - Creates an
ANNOUNCEMENT_THREADwhen called on aGUILD_ANNOUNCEMENTchannel
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:
-
message(str | MessagePart) –content as a string or MessagePart
-
flags(MessageFlagParams, default:{}) –flags to set
Returns:
-
MessageModel–created message
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:
-
list[InviteWithMetadataModel]–list[InviteWithMetadataModel]: queried list of invites
create_invite
async
¶
Create a new invite for this channel.
Fires InviteCreateEvent.
Permissions
Requires CREATE_INSTANT_INVITE
Parameters:
-
invite(InvitePart) –invite to create
Returns:
-
InviteModel–created invite object
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:
-
ThreadMemberModel–queried thread member
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:
-
list[ThreadMemberModel]–queried list of thread members
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:
-
ChannelModel(ChannelModel) –new thread
create_thread_without_message
async
¶
Create a thread not connected to an existing message.
Fires ThreadCreateEvent.
Parameters:
-
thread(ThreadWithoutMessagePart) –thread to create
Returns:
-
ChannelModel(ChannelModel) –new thread
edit_thread
async
¶
Edit this thread.
Fires ChannelUpdateEvent.
Permissions
Requires MANAGE_CHANNELS
Important
Requires archived be False or set to False.
Parameters:
-
options(EditThreadChannelParams, default:{}) –channel fields to edit
Returns:
-
ChannelModel–updated channel
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:
-
ArchivedThreadsModel–queried public archived threads
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:
-
ArchivedThreadsModel–queried private archived threads
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:
-
ArchivedThreadsModel–queried private archived threads