Giter VIP home page Giter VIP logo

descord's Introduction

descord

A discord API wrapper written using TypeScript for deno.

This library is in its pre-alpha state. For now, you can connect the discord bot to the discord servers. The library will automatically handle sharding for you. A sample bot written in the library is given below.

// Import the client from github.
import { Client } from 'https://raw.githubusercontent.com/TheDrone7/descord/pre-alpha/mod.ts';

// Instantiate a new client.
const client = new Client();

// Handle debug messages
client.on('debug', console.log);

// Handle raw websocket events
client.on('raw', (raw: any) => {
	console.log(`Event fired: ${raw.t}`);
});

// Handle ready event.
client.on('ready', () => {
   console.log(`Logged in as ${client.user.tag}`);
});

client.login('My bot token here!', {
    status: 'dnd'
});

You can also send ws messages using the wsSend() method of the client. For example: -

client.wsSend({
    op: 3,
    d: {
        status: 'dnd',
        afk: false,
        game: {
            name: 'descord',
            type: 4
        }
    }
});

For making http request to the discord's REST API, you can use the built-in fetch API system or use the client's HTTPClient as shown below: -

let user = await client.http.get('/users/374886124126208000');
if (user.status === 200) console.log(user.body);
else console.error(user.statusText);

descord's People

Contributors

thedrone7 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.