> ## Documentation Index
> Fetch the complete documentation index at: https://www.chapterjs.org/llms.txt
> Use this file to discover all available pages before exploring further.

# ThreadChannel

> A thread or a forum post: archive, lock, members and tags

A `ThreadChannel` is a thread, or a post of a forum. It is what `channel.isThread()` gives, and what `message.startThread()`, `channel.startThread()` and `forum.createPost()` return.

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
import type { ThreadChannel } from 'chapterjs';

async function close(thread: ThreadChannel, reason: string) {
  if (thread.archived) return;
  await thread.send(`Closing this thread: ${reason}`);
  await thread.edit({ archived: true, locked: true }, reason);
}
```

> [!NOTE]
>
> How to send, edit and read messages is in [Sending messages](https://www.chapterjs.org/messages.md).

## Properties

It also has everything of [Channel](https://www.chapterjs.org/reference/channels#channel) and [what channels with messages share](https://www.chapterjs.org/reference/channels#channels-with-messages). A thread is not a `GuildChannel`: it has no overwrites of its own, and takes the permissions of the channel it is in.

**guildId** `Snowflake`

The id of the server of the thread.

**guild** `Guild`

The server of the thread.

**name** `string`

The name of the thread.

**parentId** `Snowflake`

The id of the channel the thread was created in.

**parent** `TextChannel | ForumChannel | null`

The channel the thread was created in; `null` when it is of a kind this version does not know.

**ownerId** `Snowflake | null`

The id of the user who created the thread.

**archived** `boolean`

Whether the thread is archived.

**locked** `boolean`

Whether only moderators can unarchive it.

**isPrivate** `boolean`

Whether only invited members and moderators can see it.

**archivedAt** `Date | null`

When the thread was archived or unarchived for the last time.

**memberCount** `number`

An approximate count of the members of the thread (stops at 50).

**appliedTags** `readonly Snowflake[]`

The ids of the tags of the post, in a forum.

## Helpers

### permissionsFor()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
permissionsFor(member: GuildMember): Permissions
```

Threads inherit the permissions of the channel they are in.

## Reading from Discord

### fetchMembers()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
fetchMembers(options?: { limit?: number; after?: Snowflake }): Promise<ThreadMember[]>
```

Who is in the thread (100 at most per call). Each entry is a [`ThreadMember`](https://www.chapterjs.org/reference/data#threadmember).

[Discord documentation](https://docs.discord.com/developers/resources/channel#list-thread-members)

## Actions

### edit()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
edit(options: ThreadEditOptions, reason?: string): Promise<this>
```

Changes the thread: name, archive, lock, slowmode, tags. The options are a [`ThreadEditOptions`](https://www.chapterjs.org/reference/options#threadeditoptions).

[Discord documentation](https://docs.discord.com/developers/resources/channel#modify-channel)

### archive()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
archive(reason?: string): Promise<this>
```

Archives the thread: it leaves the channel list but can come back.

[Discord documentation](https://docs.discord.com/developers/resources/channel#modify-channel)

### unarchive()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
unarchive(reason?: string): Promise<this>
```

Brings an archived thread back.

[Discord documentation](https://docs.discord.com/developers/resources/channel#modify-channel)

### join()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
join(): Promise<void>
```

Makes the bot join the thread.

[Discord documentation](https://docs.discord.com/developers/resources/channel#join-thread)

### leave()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
leave(): Promise<void>
```

Makes the bot leave the thread.

[Discord documentation](https://docs.discord.com/developers/resources/channel#leave-thread)

### addMember()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
addMember(user: Snowflake | { id: Snowflake }): Promise<void>
```

Adds a member to the thread.

[Discord documentation](https://docs.discord.com/developers/resources/channel#add-thread-member)

### removeMember()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
removeMember(user: Snowflake | { id: Snowflake }): Promise<void>
```

Removes a member from the thread.

[Discord documentation](https://docs.discord.com/developers/resources/channel#remove-thread-member)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.