A Discord api Wrapper Written in Node.js, and Soon to be in Deno

daubu

A discord API wrapper library for nodejs, and maybe deno. (oh god please help my soul)

I should note: DO NOT USE THIS LIBRARY it barely works, and I’ve taken code from other libraries. It’s only on NPM for testing purposes.

Why?

Honestly, I’ve been working on neocord, which is an upcoming discord library. So I’m deciding to make my own, because I actually somehow got interested in making a discord lib. I’m more comfortable with node.js right now, so deno probably won’t happen for awhile. But yeah, why not?

Example

Using discord’s v8 API

const { Client } = require("daubu");
const bot = new Client({
  token: "your token here",
  intents: ["GUILDS", "GUILD_MESSAGES"], // you will need intents using the V8 API
})

bot.on("ready", () => console.log(`Logged in as ${bot.user.tag} (${bot.user.id})`));

bot.on("messageCreate", (msg) => {
  const prefix = "!";

  if (!msg.content.startsWith(prefix) || msg.author.bot) {
    return;
  }

  const [cmd] = msg.content.slice(prefix.length).trim().split(/ +/g);

  if (cmd === "hello") {
    return msg.channel.send(`Hey there, ${msg.author.username}!`);
  }
})

bot.connect();

Using the legacy v6 API

const { Client } = require("daubu");
const bot = new Client({
  token: "your token here",
  ws: {
    v: 6, // sets the API version to v6
  }
})

bot.on("ready", () => console.log(`Logged in as ${bot.user.tag} (${bot.user.id})`));

bot.on("messageCreate", (msg) => {
  const prefix = "!";

  if (!msg.content.startsWith(prefix) || msg.author.bot) {
    return;
  }

  const [cmd] = msg.content.slice(prefix.length).trim().split(/ +/g);

  if (cmd === "hello") {
    return msg.channel.send(`Hey there, ${msg.author.username}!`);
  }
})

bot.connect();

Credits

  • neocord This library’s sharding was heavily inspired by neocord
  • discordjs The Collection class idea
  • eris Compression for the shard. I don’t understand a thing about zlib.

If you are a maintainer of either of these orgs, and you have a problem please DM me on discord (aesthetical#2545) or make an issue on the repo.

Download Details:

Author: Sxmurai

Source Code: https://github.com/Sxmurai/daubu

#deno #nodejs #node #javascript

A Discord api Wrapper Written in Node.js, and Soon to be in Deno
5.25 GEEK