diff --git a/README.md b/README.md index 9fbf3f57..2ab36ef9 100644 --- a/README.md +++ b/README.md @@ -1,95 +1,61 @@ # revolt.js +> **Warning** +> revolt.js is currently being rewritten, it's pretty much ready for use for most applications but is still not entirely feature complete. +> +> You can find the [version 6 README here](https://github.com/revoltchat/revolt.js/tree/v6). +   -**revolt.js** is a direct implementation of the entire Revolt API and provides a way to authenticate and start communicating with Revolt servers. +**revolt.js** is a JavaScript library for interacting with the entire Revolt API. -## Example Usage (Javascript / ES6) +## Example Usage ```javascript +// esm / typescript import { Client } from "revolt.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) - -```javascript +// ...or commonjs const { Client } = require("revolt.js"); let client = new Client(); client.on("ready", async () => - console.info(`Logged in as ${client.user.username}!`), + console.info(`Logged in as ${client.user.username}!`) ); -client.on("message", async (message) => { - if (message.content === "hello") { - message.channel.sendMessage("world"); - } +client.on("messageCreate", async (message) => { + if (message.content === "hello") { + message.channel.sendMessage("world"); + } }); client.loginBot(".."); ``` -## Example Usage (Typescript) +## Reactivity with Signals & Solid.js Primitives -```typescript -import { Client } from "revolt.js"; +All objects have reactivity built-in and can be dropped straight into any Solid.js project. -let client = new Client(); +```tsx +const client = new Client(); +// initialise the 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. - -```typescript -import { autorun } from 'mobx'; - -[..] - -client.once('ready', () => { - autorun(() => { - console.log(`Current username is ${client.user!.username}!`); - }); -}); +function MyApp() { + return ( +