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.
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.
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.
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.
Parameters:
-
kwargs
(Unpack[PinsFetchParams]
, default:{}
) –field-specific data
Note
If no kwargs are provided, default to 50 fetched messages limit.
Returns:
-
list[PinnedMessage]
–list of pinned messages
delete
async
¶
Deletes this channel from the server.
PinnedMessage
dataclass
¶
PinsFetchParams
¶
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.