Skip to main content
Deno 2 is finally here šŸŽ‰ļø
Learn more

THIS BRANCH IS OUT-OF-DATE, PLEASE CHECK dev INSTEAD; BASICALLY EVERYTHING IS THERE UNTIL IT’S STABLE!

THIS LIBRARY IS UNDERDEVELOPMENT & AREN’T MEANT TO BE USED IN PRODUCTION YET!

dcord

Library to interact with Discord’s API on the Deno javascript/typescript runtime.

setup

First you need to have Deno runtime installed on your machine. Install it here.

After that is done, make sure you have it by doing following command on PS/cmd/bash:

$ deno info

If it does not tell that the command doesn’t exists, you have successfully installed deno runtime!

installation

There’s no ā€œinstallationā€ needed, just include the https://deno.land/x/ url in your file.

Example in usage:

// Importing the library itself as "DCord"
// Take a note that this is taken from `dev` branch, so until it's stable, use that
// after it's stable, please make sure you change that `dev` into `main`
import * as DCord from "https://raw.githubusercontent.com/u59/dcord/dev/mod.ts";

// Creating the client itself, you pass token into the constructor, and possibly a boolean to the constructor what tells the client should it connect automatically or not.
const client = new DCord.Client("your.very.secret.token");

// Event fired once the client is ready to serve requests
client.once("ready", () => console.log("I'm ready!"));

// Event fired once bot receives NEW message
client.on("messageCreate", (message: any) => {
    if (message.content.startsWith("ping") && !message.author.bot)
    {
        return client.createMessage(message.channel_id, "Pong!");
    }
});

// You might have been conformtable with something like `client.connect()` or `client.login()`, but this library doesn't require it. (major changes can happen lol)

To start the bot, simply run this command on your command line:

$ deno run --allow-net index.ts

Contribution is appreciated! :3