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

# GuildMember

> Read the nickname, roles and permissions of a member and moderate them: timeout, kick, ban

A `GuildMember` is a [user](https://www.chapterjs.org/reference/user.md) as a member of one server: the same person has one `User`, and one `GuildMember` per server they are in. You get one as the `member` of a [command](https://www.chapterjs.org/reference/interaction.md) used in a server, with the events about members and messages, and from `guild.members` or `guild.fetchMember()`.

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

async function mute(member: GuildMember, moderator: GuildMember) {
  if (!moderator.permissions.has('ModerateMembers')) return 'You are not allowed to do that.';
  if (!moderator.isHigherThan(member)) return 'You can only time out members below you.';
  await member.timeout(10 * 60 * 1000, `Timed out by ${moderator.displayName}`);
  return `${member.displayName} is timed out for 10 minutes.`;
}
```

> [!NOTE]
>
> How your functions receive a member is in [Commands](https://www.chapterjs.org/commands.md) and [Events](https://www.chapterjs.org/events.md). Which members the bot remembers is in [Memory](https://www.chapterjs.org/memory.md).

## Properties

**guildId** `Snowflake`

The id of the server.

**user** `User`

The account of the member.

**id** `Snowflake`

The id of the user.

**guild** `Guild`

The server the member is in.

**nick** `string | null`

The nickname of the member in this server, when they have one.

**displayName** `string`

The name to show: nickname, or display name, or username.

**roleIds** `readonly Snowflake[]`

The ids of the roles of the member (@everyone is not listed).

**roles** `Role[]`

The roles of the member, @everyone included, highest first.

**highestRole** `Role`

The highest role of the member in the hierarchy; @everyone at least.

**voiceChannel** `VoiceChannel | null`

The voice channel the member is in; `null` when they are in none. The bot knows it when Discord sends it voice states: in a project with a file that joins a voice channel or listens to a voice event.

**joinedAt** `Date | null`

When the member joined the server.

**boostingSince** `Date | null`

Since when the member boosts the server.

**pending** `boolean`

Whether the member has not passed the membership screening yet.

**timeoutUntil** `Date | null`

Until when the member is timed out; `null` when they are not.

**isTimedOut** `boolean`

Whether the member is timed out right now.

**isOwner** `boolean`

Whether the member owns the server.

**permissions** `Permissions`

What the member can do in the server (channels may change it: see `permissionsIn`). See [Permissions](https://www.chapterjs.org/reference/permissions.md).

## Helpers

These read what the bot remembers: they never send a request.

### permissionsIn()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
permissionsIn(channel: GuildChannel): Permissions
```

What the member can do in a channel of the server.

### avatarURL()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
avatarURL(options?: ImageOptions): string
```

The avatar of the member in this server, or else of their account. See [ImageOptions](https://www.chapterjs.org/reference/helpers.md#imageoptions).

### isHigherThan()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
isHigherThan(other: GuildMember): boolean
```

Whether this member is above another one in the role hierarchy, which is what allows to kick, ban or rename them.

[Discord documentation](https://docs.discord.com/developers/topics/permissions#permission-hierarchy)

### hasRole()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
hasRole(role: Snowflake | Role): boolean
```

Whether the member has a role.

### toString()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
toString(): string
```

`<@id>`: mentions the member when put in a message.

### toJSON()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
toJSON(): object
```

The data of Discord as a plain object, with camelCase names.

## Actions

### edit()

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

Changes the member. See [MemberEditOptions](#membereditoptions).

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

### setNick()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
setNick(nick: string | null, reason?: string): Promise<GuildMember>
```

Changes the nickname of the member; `null` removes it.

### addRole()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
addRole(role: Snowflake | Role, reason?: string): Promise<void>
```

Gives a role to the member.

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

### removeRole()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
removeRole(role: Snowflake | Role, reason?: string): Promise<void>
```

Takes a role from the member.

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

### timeout()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
timeout(duration: number, reason?: string): Promise<GuildMember>
```

Prevents the member from writing, reacting and speaking for a while. `duration` is how long, in milliseconds (28 days at most).

### removeTimeout()

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

Ends the timeout of the member.

### kick()

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

Removes the member from the server; they can come back with an invite.

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

### ban()

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

Bans the member from the server. See [BanOptions](#banoptions).

[Discord documentation](https://docs.discord.com/developers/resources/guild#create-guild-ban)

### send()

```ts theme={"theme":{"light":"github-light","dark":"vesper"}}
send(message: MessageInput): Promise<Message>
```

Sends a private message to the member. See [MessageInput](https://www.chapterjs.org/reference/message-options.md#messageinput).

## Types

### BanOptions

What `ban()` takes, on a member or on a [server](https://www.chapterjs.org/reference/guild.md#ban). Every field can be left out.

**reason** `string`

Why, shown in the audit log of the server.

**deleteMessageSeconds** `number`

Also deletes the messages the user sent in the last seconds given: from 0 (the default, nothing) to 604800 (7 days).

### MemberEditOptions

What `edit()` takes. Every field can be left out: only what you pass changes.

**nick** `string | null`

The nickname; `null` removes it.

**roles** `(Snowflake | Role)[]`

Replaces every role of the member.

**mute** `boolean`

Mutes the member in voice channels.

**deaf** `boolean`

Deafens the member in voice channels.

**voiceChannel** `Snowflake | \{ id: Snowflake \} | null`

Moves the member to another voice channel; `null` disconnects them.

**timeoutUntil** `Date | null`

Until when the member is timed out; `null` ends the timeout.


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