Skip to main content
Version: 0.9.1

Class: GroupChannel

The base class for all structures.

Extends​

Constructors​

Constructor​

new GroupChannel(client, data): GroupChannel

Parameters​

ParameterType
clientClient
data{ }

Returns​

GroupChannel

Overrides​

BaseChannel.constructor

Properties​

cachedAt​

cachedAt: number

Inherited from​

BaseChannel.cachedAt


client​

protected readonly client: Client

Inherited from​

BaseChannel.client


createdAt​

createdAt: Date


createdTimestamp​

createdTimestamp: number


description?​

optional description?: string | null = null


icon​

icon: Attachment | null = null


id​

readonly id: string

Inherited from​

BaseChannel.id


lastMessageId?​

optional lastMessageId?: string | null = null


messages​

messages: MessageManager

Inherited from​

BaseChannel.messages


name​

name: string


nsfw​

nsfw: boolean = false


ownerId​

ownerId: string


recipients​

recipients: string[] = []


type​

type: ChannelType

Inherited from​

BaseChannel.type

Accessors​

owner​

Get Signature​

get owner(): User | undefined

Gets the User object of the person who owns this group

Returns​

User | undefined


recipientUsers​

Get Signature​

get recipientUsers(): User[]

Resolves the recipient IDs into an array of cached User objects

Returns​

User[]

Methods​

_clone()​

_clone(): this

Helper to quickly clone a structure

Returns​

this

Inherited from​

BaseChannel._clone


_patch()​

_patch(data, clear?): void

Parameters​

ParameterType
data{ }
clear?("Description" | "Icon" | "DefaultPermissions" | "Voice" | "Slowmode")[]

Returns​

void


[custom]()​

[custom](_depth, options, inspect): string

Parameters​

ParameterType
_depthnumber
optionsInspectOptions
inspecttypeof inspect

Returns​

string


awaitMessages()​

awaitMessages(options?): Promise<Collection<string, Message>>

Awaits messages in this channel that meet certain criteria.

Parameters​

ParameterTypeDescription
optionsMessageCollectorOptionsThe options for the collector.

Returns​

Promise<Collection<string, Message>>

A promise that resolves to a collection of messages.

Example​

// Await !vote messages
const filter = m => m.content.startsWith('!vote');
channel.awaitMessages({ filter, max: 4, time: 60000 })
.then(collected => console.log(collected.size))
.catch(console.error);

Inherited from​

BaseChannel.awaitMessages


bulkDelete()​

bulkDelete(messages): Promise<void>

Bulk delete messages from this channel

Parameters​

ParameterTypeDescription
messagesMessageResolvable[]MessageResolvable to delete

Returns​

Promise<void>

Throws​

If the API request fails

Example​

// Delete messages by their ID's
await channel.bulkDelete(["MESSAGE_ID_1", "MESSAGE_ID_2", "MESSAGE_ID_3"]);
// Delete messages by their Message objects
await channel.bulkDelete([message1, message2, message3]);

Inherited from​

BaseChannel.bulkDelete


createMessageCollector()​

createMessageCollector(options?): MessageCollector

Creates a MessageCollector to collect messages in this channel.

Parameters​

ParameterTypeDescription
options?MessageCollectorOptionsThe options for the collector.

Returns​

MessageCollector

The instantiated MessageCollector

Example​

const collector = channel.createMessageCollector({ filter: m => m.authorId === '123', time: 15000 });
collector.on('collect', m => console.log(`Collected ${m.content}`));
collector.on('end', collected => console.log(`Collected ${collected.size} items`));

Inherited from​

BaseChannel.createMessageCollector


delete()​

delete(): Promise<void>

Deletes this channel.

Returns​

Promise<void>

Throws​

If the API request fails

Example​

// Delete the channel
await channel.delete();

Inherited from​

BaseChannel.delete


edit()​

edit(options): Promise<BaseChannel>

Edits this channel.

Parameters​

ParameterTypeDescription
optionsChannelEditOptionsThe fields to update

Returns​

Promise<BaseChannel>

BaseChannel

Throws​

If the API request fails

Example​

// Edit the channel's name
await channel.edit({name: "New Cool Name"});

Inherited from​

BaseChannel.edit


equals()​

equals(other): boolean

Compares this object with another to see if they represent the same entity.

Parameters​

ParameterType
otherstring | Base

Returns​

boolean

Inherited from​

BaseChannel.equals


fetch()​

fetch(force?): Promise<BaseChannel>

Fetch this channel

Parameters​

ParameterTypeDefault valueDescription
forcebooleanfalseWhether to skip the cache check and force a direct API request. Defaults to false

Returns​

Promise<BaseChannel>

Throws​

If the API request fails

Example​

// Force fetch channel to update its data
await channel.fetch(true);

Inherited from​

BaseChannel.fetch


fetchMessages()​

fetchMessages(options?): Promise<Collection<string, Message>>

Fetches multiple messages from this channel.

Parameters​

ParameterTypeDescription
options?MessageFetchOptionsThe query parameters to filter the messages.

Returns​

Promise<Collection<string, Message>>

A Collection of Messages, keyed by their ID.

Throws​

If the API request fails

Example​

// Fetch the last 50 messages in the channel
const messages = await channel.fetchMessages({ limit: 50 });
console.log(`Fetched ${messages.size} messages`);
// Fetch messages before a specific message ID
const messages = await channel.fetchMessages({ before: "MESSAGE_ID" });
console.log(`Fetched ${messages.size} messages sent before the specified message`);
// Fetch messages after a specific message ID
const messages = await channel.fetchMessages({ after: "MESSAGE_ID" });
console.log(`Fetched ${messages.size} messages sent after the specified message`);
// Fetch messages around a specific message ID
const messages = await channel.fetchMessages({ around: "MESSAGE_ID", limit: 10 });
console.log(`Fetched ${messages.size} messages sent around the specified message`);

Inherited from​

BaseChannel.fetchMessages


isDM()​

isDM(): this is DMChannel

Returns​

this is DMChannel

Inherited from​

BaseChannel.isDM


isGroup()​

isGroup(): this is GroupChannel

Returns​

this is GroupChannel

Inherited from​

BaseChannel.isGroup


isText()​

isText(): this is TextChannel

Returns​

this is TextChannel

Inherited from​

BaseChannel.isText


isVoice()​

isVoice(): this is VoiceChannel

Returns​

this is VoiceChannel

Inherited from​

BaseChannel.isVoice


send()​

send(contentOrOptions): Promise<Message>

Sends a message to this channel.

Parameters​

ParameterTypeDescription
contentOrOptionsstring | MessageOptionsThe string content or message options payload.

Returns​

Promise<Message>

A promise that resolves to the sent Message.

Example​

await channel.send("Hello world!");
await channel.send({ content: "Here is an embed", embeds: [myEmbed] });

Inherited from​

BaseChannel.send


setDefaultPermissions()​

setDefaultPermissions(permissions): Promise<GroupChannel>

Updates the default (everyone) permissions for this channel.

Parameters​

ParameterTypeDescription
permissionsPermissionResolvableThe default permissions to grant globally in this channel.

Returns​

Promise<GroupChannel>

A promise that resolves to the updated BaseChannel.

Throws​

If invalid permissions are provided.

Throws​

If the API request fails.

Example​

// Set the default permission to allow everyone to view the channel
await channel.setDefaultPermissions(["ViewChannel", "ReadMessageHistory"]);

toString()​

toString(): string

Returns the UUID string when the object is cast to a string.

Returns​

string

Inherited from​

BaseChannel.toString