Skip to content

Hearing a server

Your wisp hears what happens in the servers it is in, as events. Handle the ones you want, and pass over the rest before your code does any work:

wisp.When<MessageCreated>()
.InChannel(general)
.Containing("hello")
.Do(e => wisp.ReactAsync(e.Message.Id, ":wave:"));
// welcomes: the welcome channel you keep for each server.
wisp.When<MemberJoined>()
.Where(e => welcomes.ContainsKey(e.Server))
.Do(e => wisp.SendAsync(
welcomes[e.Server], $"Welcome, @{e.Member.Name}!"));

Filters: InServer, InChannel, Containing, From, and Where for anything else. A route never changes, so a route kept in a variable can be narrowed in more than one way. Without a filter: wisp.On<ServerJoined>(e => ...).

What your wisp hears in a server is what that server’s admin let it hear (How a server lets it in):

Item Events For
always ServerJoined then GrantsChanged, ServerLeft, and the runs, presses and sendings of its own knowing where it is
The server’s shape (shape) ServerUpdated, ChannelUpdated, ChannelDeleted, LayoutUpdated, RolesUpdated, EmojiUpdated, EmojiDeleted keeping a map of the server
Members (members) MemberJoined, MemberRolesChanged, MemberLeft welcomes, auto-roles, logs
Messages (messages) MessageCreated, MessageEdited, MessageDeleted, ReactionChanged, in the channels it works in levels, moderation, replies

In TypeScript each event has the same name, starting in lowercase: serverJoined, messageCreated.

Your wisp never hears typing, who is online, read marks, anyone’s inbox, or messages between people in DMs. It never hears its own new lines, edits or reactions back: it knows what it did.

Added to a server, your wisp hears ServerJoined, the server as it is, then GrantsChanged with what the admin gave it there. GrantsChanged comes again, whole, each time an admin saves a change, so take each one as the grant as it stands now. Its grant says what you have:

  • e.Grants.CanHear("messages") and CanDo("react"): what it may hear and do there.
  • Covers(channel): whether it works in that channel. Everywhere is true when it works in every channel, those made later too; otherwise Channels names them.
  • Has(Permission.KickMembers): its server permissions.

The channels can be empty: every channel the admin picked was deleted, and your wisp works in no channel there until an admin picks again. It never means every channel.

wisp.When<GrantsChanged>()
.Where(e => !e.Grants.CanDo("post"))
.Do(e => Console.WriteLine($"Cannot post in {e.Server} any more"));

Taken out of a server, kicked or banned, it hears ServerLeft with the reason, and nothing more of that server.

Runs and presses start one at a time in the order they came, each until its first await, so a game sees its presses in order; while one waits, the next starts. Events about one server reach your handlers in order, one at a time, and servers never wait for each other. A handler that throws is logged and your wisp carries on.

Reads come as streams, a page at a time, so you read only the pages you use:

// Everything said in a channel since a moment, oldest first.
await foreach (var message in wisp.MessagesSinceAsync(channel, lastSeen))
Count(message);
// Ana's lines from the last day, newest first.
var hers = await wisp.MessagesBeforeAsync(channel)
.TakeWhile(m => m.At > DateTimeOffset.UtcNow.AddDays(-1))
.Where(m => m.Author == ana)
.ToListAsync();
// The server's members, and one of them (null when they are not in it).
var wisps = await wisp.MembersAsync(server).CountAsync(m => m.IsWisp);
Member? one = await wisp.MemberAsync(server, user);

LINQ over these streams is built into .NET 10; on .NET 8, add the System.Linq.AsyncEnumerable package.

A read needs the item for what it reads: Messages in that channel, or Members. Bound a read by time or by how many you take, so a filter that rarely matches never walks a channel’s whole history.


Writing your own library? Every event’s frame is in What a wisp hears, raw.

© 2026 Woosh AS. All rights reserved.