Skip to content

Commands

A command is a method marked with [Command]. Its parameters are the command’s options, which the person fills in after the /. Put as many commands as you like in one class and add it with one call:

using Woosh.Wisp;
public enum Wrap { Plain, [Choice("Gold paper")] Gold }
public sealed class Gifts(Bank bank)
{
[Command("gift", "Give someone coins")]
public async Task Gift(
CommandRun run,
[Option("Who gets them")] MemberId to,
[Option("How many")] int amount,
Wrap wrap = Wrap.Plain)
{
if (!bank.Move(run.User.Id, to, amount))
{
await run.AnswerPrivatelyAsync("You don't have that many coins.");
return;
}
var color = wrap == Wrap.Gold ? "#eab308" : "#22c55e";
var giver = Mark.User(run.User.Id);
var given = $"{giver} gave {Mark.User(to)} {amount} coins.";
var card = new Card(color).Text(given);
await run.AnswerAsync($"{run.User} gave {amount} coins.", card);
}
[Command("balance", "How many coins you have")]
public Task Balance(CommandRun run) =>
run.AnswerPrivatelyAsync($"You have {bank[run.User.Id]:N0} coins.");
}
wisp.AddCommands(new Gifts(bank));

Each parameter’s type says what the person gives:

Parameter What the person gives
string words
int, long, short, byte a whole number
double, float, decimal a number
MemberId a member of the server, picked from a list
ChannelId, RoleId a channel or a role of the server, picked from a list
an enum one of its values (up to 25), picked from a list
CommandRun nothing: the run itself, who ran it and where
CancellationToken nothing: it ends with the run’s 15 seconds
  • An option is required unless its parameter is nullable (int?, MemberId?) or has a default (int bet = 10). Left out, it takes that default.
  • Its name is the parameter’s, in lowercase with dashes (betAmount is bet-amount), and so are an enum’s values. [Option("What it is for")] describes it, and Name = "..." renames it. [Choice("Gold paper")] on an enum value changes the words the picker shows.
  • A number that does not fit its parameter, such as 2.5 for an int, never reaches your code: the person is told privately and your method does not run.

Mistakes are build errors, where you made them and in plain words. Nothing is looked up when your wisp runs: the library writes the code that adds your commands as your project builds.

Dice.cs(6,58): error WISP003: 'loud' is a Boolean: an option is a string, a number type,
MemberId, ChannelId, RoleId or an enum. Woosh has no yes-or-no option: an enum with Yes and No
is a choice.

A wisp has up to 50 commands, each with up to 10 options.

A run is answered once, within 15 seconds. The person’s app shows your wisp working on it from the moment they run it, so there is nothing to acknowledge first.

Answer Shows
run.AnswerAsync(text, card?), run.AnswerAsync(card) a line in the channel, with “ana used /gift” above it. Returns the line’s id
run.AnswerPrivatelyAsync(text, card?), run.AnswerPrivatelyAsync(card) a private answer: only the person sees it, and Woosh keeps it nowhere
run.AskAsync(form) a form for the person to fill in and send

run.User is who ran it, run.Channel and run.Server are where. Writing run.User into words writes the person’s name.

A line’s words are plain text, and @name in them mentions a member.

Slow work answers first. Answer at once, then edit your own line when the work is done:

var line = await run.AnswerAsync("Drawing a winner...");
var winner = await DrawWinnerAsync();
await wisp.EditAsync(line, $"The winner is @{winner.Name}!");

A run that is not answered within 15 seconds tells the person your wisp did not answer.

A command is offered in the channels where the server’s admin let your wisp work, and only once your wisp has the Commands item in that server (How a server lets it in). The list people see is the one your wisp sent when it last started.

When your commands come from data, such as one game per row of a table, build them in a loop:

foreach (var game in games)
wisp.Command(game.Name, game.Description)
.Number("bet", "Coins to bet", required: true)
.Handle(run => game.PlayAsync(run, run.Options.Integer("bet")!.Value));

Options: Text, Number, Member, Channel, Role and Choice. Read them with run.Options.Text("name"), .Number, .Integer, .Member, .Channel, .Role and .Choice.

A list that breaks a rule throws as you build it. Woosh takes a new list at most every 15 seconds, so build it once, before your wisp starts.


Writing your own library? The frames underneath are in Commands, raw.

© 2026 Woosh AS. All rights reserved.