Ananke.Platforms.Discord
0.7.2
dotnet add package Ananke.Platforms.Discord --version 0.7.2
NuGet\Install-Package Ananke.Platforms.Discord -Version 0.7.2
<PackageReference Include="Ananke.Platforms.Discord" Version="0.7.2" />
<PackageVersion Include="Ananke.Platforms.Discord" Version="0.7.2" />
<PackageReference Include="Ananke.Platforms.Discord" />
paket add Ananke.Platforms.Discord --version 0.7.2
#r "nuget: Ananke.Platforms.Discord, 0.7.2"
#:package Ananke.Platforms.Discord@0.7.2
#addin nuget:?package=Ananke.Platforms.Discord&version=0.7.2
#tool nuget:?package=Ananke.Platforms.Discord&version=0.7.2
Ananke.Platforms.Discord
Discord adapter for Ananke - bridges Discord Gateway events to Ananke agent workflows via IMessagePlatformAdapter. Supports streaming chat responses using the post-then-edit pattern with automatic debouncing.
Install
dotnet add package Ananke.Platforms.Discord
Prerequisites
- Create a Discord Application at discord.com/developers
- Under Bot, click Reset Token and copy the bot token
- Under Bot > Privileged Gateway Intents, enable Message Content Intent
- Under OAuth2 > URL Generator, select scopes
bot+ permissionsSend Messages,Read Message History,Add Reactions - Use the generated URL to invite the bot to your server
Quick start
using Ananke.Platforms;
using Ananke.Platforms.Discord;
services.AddAnankeDiscord(options =>
{
options.BotToken = config["Discord:BotToken"]!;
});
services.AddSingleton<IPlatformMessageHandler, MyAgentHandler>();
What it registers
| Service | Implementation |
|---|---|
IMessagePlatformAdapter |
DiscordAdapter - connects via Discord Gateway (WebSocket), dispatches incoming messages |
IPlatformResponseSink |
DiscordResponseSink - sends/edits messages, typing indicators, reactions via Discord API |
IHostedService |
DiscordHostedService - starts/stops the adapter with the application host |
Thread support
Discord threads are mapped automatically:
| Discord context | PlatformMessage.ChannelId |
PlatformMessage.ThreadId |
|---|---|---|
| Regular channel message | Channel ID | null |
| Thread message | Parent channel ID | Thread channel ID |
Slash commands — ToolKit → /command bridge
When SlashCommandTools is set, every tool in the kit is registered as a Discord slash command on startup. Users invoke tools directly — the LLM is not involved.
var tools = new ToolKit("my-tools")
.AddTool("current_time", "Returns the current UTC time.",
() => ToolResult.Ok(DateTime.UtcNow.ToString("u")))
.AddTool("echo", "Echoes input back.", b => b
.Param("text", "The text to echo")
.OnExecute(async args => ToolResult.Ok(args.Get("text"))));
services.AddAnankeDiscord(options =>
{
options.BotToken = config["Discord:BotToken"]!;
options.SlashCommandTools = tools;
// Optional: register to a test guild for instant propagation during dev
// (global commands can take up to an hour to appear)
// options.TestGuildId = 123456789012345678;
});
This gives users /current_time and /echo text:hello in the Discord command picker with full autocomplete and type validation.
How it works
| Step | Detail |
|---|---|
| Registration | On Ready, tools are registered via BulkOverwriteGlobalApplicationCommandsAsync (atomic — stale commands from previous runs are removed) |
| Execution | SlashCommandExecuted → extract args → tool.ExecuteAsync(args) → respond with result |
| Timeout | Uses DeferAsync + FollowupAsync — no 3-second limit on tool execution |
Parameter type mapping
ToolParameter.JsonType |
Discord option type | Discord validates |
|---|---|---|
"string" |
String | Free text |
"integer" |
Integer | Whole numbers only |
"number" |
Number | Decimal numbers |
"boolean" |
Boolean | True/False toggle |
Documentation
Full docs, demos, and architecture: github.com/sevensamurai/Ananke
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Ananke.Orchestration (>= 0.7.2)
- Ananke.Platforms (>= 0.7.2)
- Discord.Net.WebSocket (>= 3.19.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.