Coder Social home page Coder Social logo

abdulrahman1s / better-revolt.js Goto Github PK

View Code? Open in Web Editor NEW
11.0 1.0 3.0 538 KB

A NodeJS Revolt library

Home Page: https://abdulrahman1s.github.io/better-revolt.js/

License: Apache License 2.0

TypeScript 100.00%
revolt node discord revoltjs

better-revolt.js's People

Contributors

abdulrahman1s avatar snazzah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

better-revolt.js's Issues

Got ReferenceError while running an example code

Here's the output error.

(node:22451) UnhandledPromiseRejectionWarning: ReferenceError
    at REST.request (/home/user/Desktop/devs/js/revoltbot/node_modules/better-revolt-js/dist/rest/REST.js:40:23)
    at REST.request (/home/user/Desktop/devs/js/revoltbot/node_modules/better-revolt-js/dist/rest/REST.js:43:25)
    at REST.request (/home/user/Desktop/devs/js/revoltbot/node_modules/better-revolt-js/dist/rest/REST.js:43:25)
    at REST.request (/home/user/Desktop/devs/js/revoltbot/node_modules/better-revolt-js/dist/rest/REST.js:43:25)
    at REST.get (/home/user/Desktop/devs/js/revoltbot/node_modules/better-revolt-js/dist/rest/REST.js:66:21)
    at Client.login (/home/user/Desktop/devs/js/revoltbot/node_modules/better-revolt-js/dist/client/Client.js:28:45)
    at Object.<anonymous> (/home/user/Desktop/devs/js/revoltbot/src/index.js:5:8)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at emitUnhandledRejectionWarning (internal/process/promises.js:168:15)
    at processPromiseRejections (internal/process/promises.js:247:11)
    at processTicksAndRejections (internal/process/task_queues.js:96:32)

and I have no idea how to fix it because there's no documentation or wiki.
OS: Linux
Node.js: v14.17.5
better-revolt.js: v0.1.0-beta

Add documentation

TODO

  • Generate documentation with typdoc
  • Host the documentation site on free hosting
  • Add description for methods and properties
  • Add examples

Unprocessable Entity error upon starting.

Upon starting the application, a Unprocessable Entity error emits:

/root/root/Revolt/node_modules/better-revolt-js/dist/rest/REST.js:63
        throw new HTTPError_1.HTTPError(res.statusText, res.constructor.name, res.status, request);
              ^

Response: Unprocessable Entity
    at REST.request (/root/root/Revolt/node_modules/better-revolt-js/dist/rest/REST.js:63:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Client.login (/root/root/Revolt/node_modules/better-revolt-js/dist/client/Client.js:40:28) {
  code: 422,
  method: 'POST',
  path: 'https://api.revolt.chat/auth/login',
  info: { retries: 0, body: {} }
}

And the code was:

const { Client } = require('better-revolt.js')

const client = new Client()

client.login({token: process,env.token})

client.on('ready', () => {
    console.log('Connected')
    console.log(client.user.username)
})

client.on('message', msg => {
    if (msg.content === '!ping') {
        msg.reply('Pong!')
    }
})

Deno compatibility

It would be nice to have a Revolt library that is compatible with Deno. I already submitted an issue on the official JavaScript library, but let's also try and get this one working. There are two ways we can go about it: SkyPack or native.

SkyPack

SkyPack is a CDN meant to convert CommonJS modules to ESM. Currently, you could use this for Deno compatibility but this loses the typings, because SkyPack isn't seeing the typings file. Fortunately, the fix is easy; define the typings file in package.json, under a typings field

Native Compatibility

This would take significantly more work but it would mean that we are able to use the same library on Deno and Node.JS, without relying on a CDN. Since Deno could also natively run TypeScript files, it would mean significantly less work for publication and updating.

There are two major things that one would have to consider before changing our repo:

  • Deno relies on module imports with the extension
  • Node.js relies on module imports without the extension

Every static import would have to be changed to a dynamic one with the following code: import('<file path>' + ("Deno" in (window || {}) ? '.ts' : ''))

Also, while Node.js relies on a node_modules folder, Deno could import modules from anywhere. This means that the above problems would exist on every module we use as a dependency. It's probably best to start from the end (aka this library) and work our way up to the dependencies.

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.