Skip to content
SinisterRectus edited this page Oct 23, 2022 · 24 revisions

extends Channel

Defines the base methods and properties for all Discord text channels.

This is an abstract base class. Direct instances should never exist.

Properties Inherited From Channel

Name Type Description
client Client A shortcut to the client object to which this container is visible.
createdAt number The Unix time in seconds at which this object was created by Discord. Additional decimal points may be present, though only the first 3 (milliseconds) should be considered accurate. Equivalent to Date.parseSnowflake(Snowflake.id).
id string The Snowflake ID that can be used to identify the object. This is guaranteed to be unique except in cases where an object shares the ID of its parent.
mentionString string A string that, when included in a message content, may resolve as a link to a channel in the official Discord client.
parent Container/Client The parent object of to which this container is a child. For example, the parent of a role is the guild in which the role exists.
timestamp string The date and time at which this object was created by Discord, represented as an ISO 8601 string plus microseconds when available. Equivalent to Date.fromSnowflake(Snowflake.id):toISO().
type number The channel type. See the channelType enumeration for a human-readable representation.

Properties

Name Type Description
messages WeakCache An iterable weak cache of all messages that are visible to the client. Messages that are not referenced elsewhere are eventually garbage collected. To access a message that may exist but is not cached, use TextChannel:getMessage.

Methods Inherited From Channel

__eq()

Defines the behavior of the == operator. Allows containers to be directly compared according to their type and __hash return values.

Returns: boolean


__hash()

Returns Snowflake.id

Returns: string


__tostring()

Defines the behavior of the tostring function. All containers follow the format ClassName: hash.

Returns: string


getDate()

Returns a unique Date object that represents when the object was created by Discord. Equivalent to Date.fromSnowflake(Snowflake.id)

This method only operates on data in memory.

Returns: Date


Methods

broadcastTyping()

Indicates in the channel that the client's user "is typing".

This method always makes an HTTP request.

Returns: boolean


getFirstMessage()

Returns the first message found in the channel, if any exist. This is not a cache shortcut; an HTTP request is made each time this method is called.

This method always makes an HTTP request.

Returns: Message


getLastMessage()

Returns the last message found in the channel, if any exist. This is not a cache shortcut; an HTTP request is made each time this method is called.

This method always makes an HTTP request.

Returns: Message


getMessage(id)

Parameter Type
id Message-ID-Resolvable

Gets a message object by ID. If the object is already cached, then the cached object will be returned; otherwise, an HTTP request is made.

This method may make an HTTP request.

Returns: Message


getMessages(limit)

Parameter Type Optional
limit number

Returns a newly constructed cache of between 1 and 100 (default = 50) message objects found in the channel. While the cache will never automatically gain or lose objects, the objects that it contains may be updated by gateway events.

This method always makes an HTTP request.

Returns: SecondaryCache


getMessagesAfter(id, limit)

Parameter Type Optional
id Message-ID-Resolvable
limit number

Returns a newly constructed cache of between 1 and 100 (default = 50) message objects found in the channel after a specific id. While the cache will never automatically gain or lose objects, the objects that it contains may be updated by gateway events.

This method always makes an HTTP request.

Returns: SecondaryCache


getMessagesAround(id, limit)

Parameter Type Optional
id Message-ID-Resolvable
limit number

Returns a newly constructed cache of between 1 and 100 (default = 50) message objects found in the channel around a specific point. While the cache will never automatically gain or lose objects, the objects that it contains may be updated by gateway events.

This method always makes an HTTP request.

Returns: SecondaryCache


getMessagesBefore(id, limit)

Parameter Type Optional
id Message-ID-Resolvable
limit number

Returns a newly constructed cache of between 1 and 100 (default = 50) message objects found in the channel before a specific id. While the cache will never automatically gain or lose objects, the objects that it contains may be updated by gateway events.

This method always makes an HTTP request.

Returns: SecondaryCache


getPinnedMessages()

Returns a newly constructed cache of up to 50 messages that are pinned in the channel. While the cache will never automatically gain or lose objects, the objects that it contains may be updated by gateway events.

This method always makes an HTTP request.

Returns: SecondaryCache


send(content)

Parameter Type
content string/table

Sends a message to the channel. If content is a string, then this is simply sent as the message content. If it is a table, more advanced formatting is allowed. See managing messages for more information.

This method always makes an HTTP request.

Returns: Message


sendf(content, ...)

Parameter Type
content string
... *

Sends a message to the channel with content formatted with ... via string.format

This method always makes an HTTP request.

Returns: Message


Clone this wiki locally