Files
javascript-client-sdk/README.md
T
Paul 0c52a4a3c9 Version 5.0 of revolt.js
Switch to MobX.
2021-07-30 17:27:22 +01:00

1.1 KiB

revolt.js

revolt.js revolt-api

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

Example Usage

let client = new Client({
    apiURL: process.env.API_URL
});

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

client.on('message', async message => {
    if (message.content === 'sus') {
        message.channel!.sendMessage('sus!');
    }
});

// Either create a new session:
client.login({ email: '..', password: '..' });

// Or use an existing session:
client.useExistingSession({ user_id: '..', session_token: '..' });

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}!`);
    });
});