GithubHelp home page GithubHelp logo

keiryojs / keiryo Goto Github PK

View Code? Open in Web Editor NEW
15.0 0.0 1.0 796 KB

๐Ÿš€ a distributed discord library

Home Page: https://discord.gg/5WD9KhF

License: MIT License

TypeScript 100.00%
discord typescript nodejs rest voice api cdn discord-api discord-gateway caching

keiryo's Introduction


NeoCord is currently in alpha, meaning it will probably be broken and might not work. If you want to contribute, please join our support server - It would be greatly appreciated.

Table of Contents

About

Neocord is a powerful and feature-rich discord library.

  • Flexible: Gives you the ability to extend specific structures, customize caching to your needs.
  • Coverage: Covers the Discord Gateway, API, CDN, and in the near future, Voice.
  • Caching: Boasts the most powerful and flexible caching solution across most discord libraries.

Installation

As of 09/04/2020 (month/day/year), NeoCord can only be used with node.js v12 and up.

yarn add neocord
Optional Packages

These are some optional packages you can install.

  • Install zlib-sync or pako for data compression and inflation

  • erlpack for significantly faster websocket (de)serialization.

  • bufferutil for a much faster websocket connection.

    And utf-8-validate for faster websocket processing.

Basic Usage

(typescript)

import { Client } from "neocord";

const client = new Client();

client
  .on("ready", () => console.log("Now ready!"))
  .on("messageCreate", (message) => {
    if (message.author.bot) return;

    const mentionPrefix = new RegExp(`^<@!${client.user.id}>\s*`);

    let prefix;
    if (message.content.startsWith("!")) prefix = "!"
    else {
      const mentioned = mentionPrefix.exec(message.content);
      if (!mentioned) return;
      prefix = mentioned[0]; 
    }
    
    const [cmd] = message.content.slice(prefix.length).split(/ /g);
    if (cmd.toLowerCase() === "ping") {
      message.channel.send("**Pong!**");
    }

    return;
  });


client.connect("your token here"); 

Links


melike2d ยฉ 2020

keiryo's People

Contributors

renovate-bot avatar rizonftw avatar viztea avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

rizonftw

keiryo's Issues

Caching Engines

As of right now, neocord only has support for memory caching... I'd like to add ways to use different methods like redis, mongodb, or any other database. But I have no idea how to do so.

Setup?

This is how I would like it to look (typescript):

import { Client, DiscordStructure } from "neocord";
import { RedisDataEngine, Sweepers } from "@neocord/engines";

const client = new Client({
  data: {
    engines: [
      new RedisDataEngine({
        handles: new Set()
          .add(DiscordStructure.Message)
          .add(DiscordStructure.Presence)
        sweepers: {
          [DiscordStructure.Message]: Sweepers.Message({
            lifetime: "30m",
            interval: "5m"
          })
        }
      })
    ]
  }
});

So here we have imported the Client and DiscordStructure.

The DiscordStructure enum is used to identify structures that can be cached within neocord like a Message, Role, etc...

We have also imported the Redis Data Engine and the Sweepers object.

The sweepers object contains pre-made sweepers for some of the structures.

In this case the redis data engine caches messages/presences and everything else will be stored within memory. I've also declared the sweepers option, only enabling a message sweeper which gets ran every 5 minutes and checks whether the message is older than 30 minutes and if it is it will be removed from the redis cache.


This is all just a very cool concept that might come to life but until there are more contributors this wont happen for quite a while.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/lint.yml
  • actions/checkout v2
  • actions/setup-node v1
npm
package.json
  • @neocord/gateway ^1.2.3
  • @neocord/rest ^1.2.0
  • @neocord/utils 1.0.15
  • discord-api-types ^0.5.0
  • tslib ^2.0.1
  • @types/node ^14.11.2
  • @typescript-eslint/eslint-plugin ^4.3.0
  • @typescript-eslint/parser ^4.3.0
  • eslint ^7.10.0
  • jsdoc ^3.6.6
  • prettier ^2.1.2
  • typescript ^4.0.3

  • Check this box to trigger a request for Renovate to run again on this repository

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.