Skip to main content
Deno 2 is finally here 🎉️
Learn more

Space

A Discord API library for Deno.

Features

  • 100% coverage over Discord’s HTTP and websocket APIs.
  • Secure by default. Client-side checks prevent 4xxs for occuring.
  • Written in TypeScript to guarantee type safety.
  • Built-in utilities such as a colorful logger.

Install

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

See the release notes for all available versions.

Getting Started

Basic program to get you started:

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

const token = prompt("token:");
if (!token) {
  throw new Error("bad token");
}

const client = new Client(token);

client.gateway.listen(
  "MESSAGE_CREATE",
  (data) => onMessageCreate(client, data),
  (message) => {
    if (message.content === "!ping") {
      client.rest.createMessage(message.channelID, {
        content: "pong!",
      });
    }
  },
);

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

See the documentation for reference.

Resources