Space

A low-level Deno module for interacting with Discord.

Features

  • Secure by default. Client-side checks prevent 4xxs from occuring.
  • Written purely in TypeScript to guarantee type safety.
  • Standalone API modules (HTTP, interactions, types, and websocket).
  • Built-in utilities such as event logging and custom caching.
  • 100% coverage over Discord’s HTTP and websocket APIs.

Install

export * from "https://deno.land/x/space@0.10.0-alpha/mod.ts";

See the release notes for all available versions.

Getting Started

Simple program to get started:

import { Client, GatewayIntentBits, onMessageCreate } from "./deps.ts";

const token = Deno.env.get("TOKEN");
const client = new Client(`Bot ${token}`);

client.connect({
  intents: GatewayIntentBits.GUILD_MESSAGES,
});

for await (const [data, shard] of client.gateway.listen("MESSAGE_CREATE")) {
  const message = await onMessageCreate(client, data);
  if (message.content === "!ping") {
    client.rest.createMessage(message.channelID, {
      content: "pong!",
    });
  }
}

To run your program:

deno run --allow-env --allow-net program.ts

See the documentation for reference.

Resources