Skip to content

Typing indicators

Each channel has a typing mode (see Typing indicators): named (the default) shows who is typing, anonymous only how many, and off nothing at all. The client knows each channel’s mode and does the right thing.

// Call on keystrokes; it sends at most what the host accepts, and nothing where typing is off.
const sent = channel.startTyping(); // false: typing is off here, nothing was sent
client.on("typingStart", ({ channel, anonymous, count, members }) => {
const text = anonymous
? count === 1 ? "Someone is typing…" : count === 2 ? "2 people are typing…" : "Several people are typing…"
: `${members.map((m) => m.displayName).join(", ")} typing…`;
showTyping(channel, text);
});
channel.typing; // now: { kind: "named", member_ids } | { kind: "anonymous", count } | null

In an anonymous channel the count is capped: 1, 2, or 3 meaning “three or more”, and your own typing is never counted. A typing state lasts a few seconds unless it’s repeated.

Needs MANAGE_CHANNELS:

await channel.setTypingMode("anonymous"); // "named", "anonymous" or "off"
channel.typingMode; // the current mode