npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

discordeno.js

v0.1.4

Published

A wrapper around Discordeno that comes with a Djs-like interface and a lot of other features.

Downloads

19

Readme

Discordeno.js

Discordeno.js is a wrapper around a very scalable library named Discordeno, which brings up a djs-like interface but also includes the core Features (Cross Ratelimit, Zero Downtime Restart, Resharding...).

Why should I change?

Djs was always meant for beginners. They way how it is built, it's not very scalable. Moreover it is bloated up with a lot of nested classes and references.

It is very noticeable that there are many breaking changes by djs. Each version has changes, most of which are very unnecessary.

Also, it's a fact that updates take a long time, you can't use new features, which happens more and more since Discord keeps introducing new features.

As example the v13 Modal PR isn't merged yet and its already 1 month, where as discordeno.js had it on the beginning date of the launch.

A migration would require breaking changes too?

We built the interface so that it can be used to switch between different libraries with very minor changes on Discordeno's side. This allows us to introduce support for other libraries, such as the Raw API.

Of course, a migration would include breaking changes, as we decided to improve the coding experience by simplifying it while incorporating high coding standards.

~~As of now, the biggest change is that ids use BigInts instead of the usual strings. This is because they use less memory. Therefore, depending on the database, you would have to stringfying the id before saving the document~~ The snowflake transformer has been overwritten to use strings instead of BigInts.

Common changes are listed in the gist, which is updated on the fly.

The wrapper supports commonly used functions such as .send, .pin, .create... . There might be a lack of other functions, but this can be easily added via a PR with a very less coding knowledge.

Features:

  • Custom Property Caching
  • Raw Cache Storage
  • Structures of common Resources (Guilds, Channels, Users, Roles, Emojis, etc.)
  • Builders for common Resources (Embeds, Components)
  • Collectors

Guide:

Documentation:

The package is on a very early stage, currently its a lacking a documentation.

Whitepaper:

Discord.Client

const Discord = require('discordeno.js');
const baseBot = Discord.createBot({
  events: {
      ready: () => {
          console.log('Ready!');
      },
      messageCreate(bot, message){
            console.log(message.content);
      }
  },
  intents: ["Guilds", "GuildMessages"],
  token: config.token,
});

const client = Discord.enableCachePlugin(baseBot, {
    guilds: {
        properties: ['id', 'members', 'name', 'roles', 'channels', 'emojis'],
    },
    roles: {
        properties: ['id', 'name', 'permissions'],
    },
    channels: {
        properties: ['id', 'name', 'type', 'messages'],
    },
    users: {
        properties: ['id', 'username', 'discriminator'],
        maxSize: 100,
    },
    members: {
        properties: ['id', 'roles', 'nickname'],
        forceSetFilter: (key, value) => {
                if (key === `${client.id}`) return true; // Sub Collection on Guild Level, pass when client user is the member
                if (key === `${client.id}${value?.guildId}`) return true; // Main Collection, pass when client user is the member of the guild
                return false;
        }
    },
    emojis: {
        properties: ['id', 'name'],
    },
    threads: {
        properties: ['id', 'channelId', 'type'],
    },
    messages: {
        properties: ['id', 'channelId', 'type'],
        // transformerClass: Discord.Message
    },
    stageInstances: {
        properties: ['id', 'guildId', 'type'],
        // transformerClass: Discord.StageInstance
    },
});
Discord.startBot(client);

Convert Discordeno Objects to Structures

Guild:

const guild = client.guilds.forge(ddGuild);

Emoji:

const emoji = client.emojis.forge(ddEmoji);

Role:

const role = client.roles.forge(ddRole);

Member:

const member = client.members.forge(ddMember);

User:

const user = client.users.forge(ddUser);

Channel:

const channel = client.channels.forge(ddChannel);

Message:

const message = client.messages.forge(ddMessage);

Get raw data of a structure:

const guild = client.guilds.cache.get(guildId);
const rawData = guild._raw;

const rawData2 = client.guilds.cache._get(guildId);
// Same accounts for other structures

Open Collector:

 // this.client.eventListener must exist, which is a eventEmitter created manually and fires when a event has been fired
 const filter = (m) => m.data?.customId === "warn_modal";
 const collector = new Collector("interactionCreate", { client: this.client, timeout: 60000, filter });

Builders:

Embed:

Component:

Bugs, glitches and issues

If you encounter any problems feel free to open an issue in our GitHub repository or join the Discord server.

Credits

All Credits goes to the discordeno library.