1.0.13 • Published 2 years ago

cyberhi.js v1.0.13

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

cyberhi.js

cyberhi.js cyberhi-api

cyberhi.js is a direct implementation of the entire cyberhi API and provides a way to authenticate and start communicating with cyberhi servers.

Example Usage (Javascript / ES6)

import { Client } from "cyberhi.js";

let client = new Client();

client.on("ready", async () =>
    console.info(`Logged in as ${client.user.username}!`),
);

client.on("message", async (message) => {
    if (message.content === "hello") {
        message.channel.sendMessage("world");
    }
});

client.loginBot("..");

If you are using Node, you must specify --experimental-specifier-resolution=node.

For example, node --experimental-specifier-resolution=node index.js.

Example Usage (CommonJS)

const { Client } = require("cyberhi.js");

let client = new Client();

client.on("ready", async () =>
    console.info(`Logged in as ${client.user.username}!`),
);

client.on("message", async (message) => {
    if (message.content === "hello") {
        message.channel.sendMessage("world");
    }
});

client.loginBot("..");

Example Usage (Typescript)

import { Client } from "cyberhi.js";

let client = new Client();

client.on("ready", async () =>
    console.info(`Logged in as ${client.user!.username}!`),
);

client.on("message", async (message) => {
    if (message.content === "hello") {
        message.channel!.sendMessage("world");
    }
});

client.loginBot("..");

MobX

MobX is used behind the scenes so you can subscribe to any change as you normally would, e.g. with mobx-react(-lite) or mobx's utility functions.

import { autorun } from 'mobx';

[..]

client.once('ready', () => {
    autorun(() => {
        console.log(`Current username is ${client.user!.username}!`);
    });
});

cyberhi API Types

All cyberhi-api types are re-exported from this library under API.

import { API } from 'cyberhi.js';

// API.Channel;
// API.[..];