GuildTextChannel - truemedian/Discordia GitHub Wiki

Inherits GuildChannel and TextChannel

Represents a text channel in a Discord guild, where guild members and webhooks can send and receive messages.

Methods

createWebhook
getWebhooks
bulkDelete
setTopic
enableNSFW
disableNSFW

Inherited from GuildChannel
setName
setCategory
moveUp
moveDown
createInvite
getInvites
getPermissionOverwriteFor
delete

Inherited from TextChannel
getMessage
getFirstMessage
getLastMessage
getMessages
getMessagesAfter
getMessagesBefore
getMessagesAround
getPinnedMessages
broadcastTyping
send
sendf

Properties

topic
nsfw
members

Inherited from Container
client
parent

Inherited from Snowflake
id
createdAt
timestamp

Inherited from Channel
type
mentionString

Inherited from GuildChannel
permissionOverwrites
name
position
guild
category

Inherited from TextChannel
messages

Methods

:createWebhook( name )

Creates a webhook for this channel. The name must be between 2 and 32 characters in length.

Name Type
name string

Returns: Webhook

:getWebhooks( )

Returns a newly constructed cache of all webhook objects for the channel. The cache and its objects are not automatically updated via gateway events. You must call this method again to get the updated objects.

Returns: Cache

:bulkDelete( messages )

Bulk deletes multiple messages, from 2 to 100, from the channel.

Name Type
messages Message ID Resolvables

Returns: boolean

:setTopic( topic )

Sets the channel's topic. This must be between 1 and 1024 characters. Pass nil to remove the topic.

Name Type
topic string

Returns: boolean

:enableNSFW( )

Enables the NSFW setting for the channel. NSFW channels are hidden from users until the user explicitly requests to view them.

Returns: boolean

:disableNSFW( )

Disables the NSFW setting for the channel. NSFW channels are hidden from users until the user explicitly requests to view them.

Returns: boolean

Inherited from GuildChannel

:setName( name )

Sets the channel's name. This must be between 2 and 100 characters in length.

Name Type
name string

Returns: boolean

:setCategory( id )

Sets the channel's parent category.

Name Type
id Channel ID Resolvable

Returns: boolean

:moveUp( n )

Moves a channel up its list. The parameter n indicates how many spaces the channel should be moved, clamped to the highest position, with a default of 1 if it is omitted. This will also normalize the positions of all channels.

Name Type
n number

Returns: boolean

:moveDown( n )

Moves a channel down its list. The parameter n indicates how many spaces the channel should be moved, clamped to the lowest position, with a default of 1 if it is omitted. This will also normalize the positions of all channels.

Name Type
n number

Returns: boolean

:createInvite( payload )

Creates an invite to the channel. Optional payload fields are: - max_age:number time in seconds until expiration, default = 86400 (24 hours) - max_uses:number total number of uses allowed, default = 0 (unlimited) - temporary:boolean whether the invite grants temporary membership, default = false - unique:boolean whether a unique code should be guaranteed, default = false

Name Type
payload table

Returns: Invite

:getInvites( )

Returns a newly constructed cache of all invite objects for the channel. The cache and its objects are not automatically updated via gateway events. You must call this method again to get the updated objects.

Returns: Cache

:getPermissionOverwriteFor( obj )

Returns a permission overwrite object corresponding to the provided member or role object. If a cached overwrite is not found, an empty overwrite with zero-permissions is returned instead. Therefore, this can be used to create a new overwrite when one does not exist. Note that the member or role must exist in the same guild as the channel does.

Name Type
obj Role

Returns: PermissionOverwrite

:delete( )

Permanently deletes the channel. This cannot be undone!

Returns: boolean

Inherited from TextChannel

:getMessage( id )

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.

Name Type
id Message ID Resolvable

Returns: Message

: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.

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.

Returns: Message

:getMessages( [ limit ] )

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.

Name Type Optional
limit number x

Returns: SecondaryCache

:getMessagesAfter( id, [ limit ] )

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

Name Type Optional
id Message ID Resolvable
limit number x

Returns: SecondaryCache

:getMessagesBefore( id, [ limit ] )

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

Name Type Optional
id Message ID Resolvable
limit number x

Returns: SecondaryCache

:getMessagesAround( id, [ limit ] )

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.

Name Type Optional
id Message ID Resolvable
limit number x

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.

Returns: SecondaryCache

:broadcastTyping( )

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

Returns: boolean

:send( content )

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.

Name Type
content string

Returns: Message

:sendf( content, ... )

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

Name Type
content string
... *

Returns: Message

Properties

.topic

The channel's topic. This should be between 1 and 1024 characters.

Type: string|nil

.nsfw

Whether this channel is marked as NSFW (not safe for work).

Type: boolean

.members

A filtered iterable of guild members that have permission to read this channel. If you want to check whether a specific member has permission to read this channel, it would be better to get the member object elsewhere and use Member:hasPermission rather than check whether the member exists here.

Type: FilteredIterable

Inherited from Container

.client

A shortcut to the client object to which this container is visible.

Type: Client

.parent

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.

Type: Container|Client

Inherited from Snowflake

.id

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.

Type: string

.createdAt

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.

Type: number

.timestamp

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: string

Inherited from Channel

.type

The channel type. See the channelType enumeration for a human-readable representation.

Type: number

.mentionString

A string that, when included in a message content, may resolve as a link to a channel in the official Discord client.

Type: string

Inherited from GuildChannel

.permissionOverwrites

An iterable cache of all overwrites that exist in this channel. To access an overwrite that may exist, but is not cached, use GuildChannel:getPermissionOverwriteFor.

Type: Cache

.name

The name of the channel. This should be between 2 and 100 characters in length.

Type: string

.position

The position of the channel, where 0 is the highest.

Type: number

.guild

The guild in which this channel exists.

Type: Guild

.category

The parent channel category that may contain this channel.

Type: GuildCategoryChannel|nil

Inherited from TextChannel

.messages

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.

Type: WeakCache

⚠️ **GitHub.com Fallback** ⚠️