discord-auto-rpc
TypeScript icon, indicating that this package has built-in type declarations

1.0.17 • Public • Published

NPM version NPM downloads Dependencies

NPM info

Discord Auto RPC

Extends the discord-rpc library to automatically reconnect on disconnect/error

Example

import { AutoClient } from "discord-auto-rpc";
// import * as DiscordRPC from "discord-auto-rpc"
// const AutoClient = DiscordRPC.AutoClient

const client = new AutoClient({ transport: "ipc" });

const setActivity = () => {
  client.setActivity({
    details: "Hello",
    state: ":)",
    startTimestamp: new Date(),
    buttons: [{ label: "Example", url: "https://example.com" }],
  });
};

client.once("ready", () => {
  setActivity();
  setInterval(setActivity, 15e3);
});

client.endlessLogin({ clientId: "797173289616801862" });

// client.endlessLogin() will keep retrying to login until it is successful (ex. wait until discord is open if its not)

// if you want to attempt to login once - client.login()
// client.login() is still able to reconnect

Note that the auto reconnecting feature is only present when using IPC as the transport

Readme

Keywords

none

Package Sidebar

Install

npm i discord-auto-rpc

Weekly Downloads

169

Version

1.0.17

License

MIT

Unpacked Size

6.72 kB

Total Files

7

Last publish

Collaborators

  • saucesteals