| .woodpecker | Add a Woodpecker workflow | |
| dotnet | store -> context and new endpoint for removing a context | |
| src | Use the Id type from twilight_model instead of u64 | |
| .gitignore | Add a client for .NET | |
| Cargo.lock | Graceful shutdown | |
| Cargo.toml | Graceful shutdown | |
| flake.lock | Add a client for .NET | |
| flake.nix | The server now exposes multiple stores thanks to the meta store | |
| LICENSE.md | Add LICENSE.md | |
| README.md | store -> context and new endpoint for removing a context | |
| taplo.toml | Drocsid now expose a REST API instead of a DSL | |
Drocsid
Drocsid is a server for testing Discord bots.
It acts as a server compatible with the Discord API.
In that way, Drocsid is similar to some really cool projects:
However, Drocsid is only used to test bots. Only the endpoints that are useful for this purpose are implemented. A Discord-compatible chat client won't be able to connect to it.
What's more, Drocsid doesn't use a persistent database; everything is stored in memory.
How to use it?
Drocsid expose three main services over HTTP with JSON:
- Two Discord compatible services:
- The bot API at
/contexts/:context_id/bot/api. - The bot gateway (a WebSocket endpoint) at
/contexts/:context_id/bot/gateway.
- The bot API at
- An API for writing tests at
/contexts/:context_id.
This design allows any language with an HTTP client and a JSON library to be used to write tests.
Using a unique identifier from your test runner as the context identifier allows to isolate tests without running multiple instances of Drocsid.
Example
Here is an example that uses the API for testing a simple /ping command.
drocsid=localhost:3000/contexts/default
# Creation of the user Turtle,
# who happens to be the guild owner.
http POST $drocsid/users name=Turtle guild_owner=true
# Creation of the General channel.
http POST $drocsid/channels name=General
# The point of starting the bot now is to ensure that it
# doesn't receive events from Turtle joining the guild
# or from the #General channel being created.
bot start
# Get a snapshot of the state to see if
# the /ping command has been created.
# We repeat this request until it exists.
http GET $drocsid/state
# Turtle executes /ping in #General.
http POST $drocsid/interactions command=ping user=Turtle channel=General
# Get a snapshot of the state for asserting the response.
http GET $drocsid/state
For the moment, this example actually shows almost everything Drocsid is capable of.
API Endpoints
DELETE /contexts/:context_id
Removes a context. The next request trying to access this context will create a new one.
GET /contexts/:context_id/api/state
Returns a snapshot of the state.
POST /contexts/:context_id/api/users
interface CreateUserRequest {
name: string;
bot?: boolean;
guild_owner?: boolean;
}
Creates an user.
POST /contexts/:context_id/api/channels
interface CreateChannelRequest {
name: string;
}
Creates a channel.
POST /contexts/:context_id/api/interactions
interface CreateInteractionRequest {
command: string;
user: string;
channel: string;
}
Creates an interaction.
Client for .NET
A client for .NET is published on nuget.
Hey that's cool!
Drocsid wants to be a common, so feel free to use it, contribute to it or discuss it. :3