discord/discord-rpc

discord-rpc not working for my client

AwesomeSam9523 opened this issue · 1 comments

This is the code i am using:

const RPC = require("discord-rpc");
const discordClient = new RPC.Client({ transport: "ipc" });

let defaultActivity;

(async () => {
    discordClient.on("ready", async () => {
        console.log('Authed for user', discordClient.user.username);
        console.log(discordClient.application.name);

        defaultActivity = {
            details: `${discordClient.user.username}`,
            state: "Test",
            largeImageKey: "test",
            largeImageText: "Kirka Client",
            smallImageText: `${discordClient.user.username}#${discordClient.user.discriminator}`,
        }

        discordClient.setActivity(defaultActivity);
    });
    await discordClient.login({clientId: "795334771718226010"}).catch(console.error)
})();

When I run the it using node app.js, it gives me the following output:

Authed for user AwesomeSam
(node:8936) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'name' of null
    at RPCClient.discordClient.on (D:\kirkaclient\discordRPC.js:9:47)
    at RPCClient.emit (events.js:198:13)
    at RPCClient.login (D:\kirkaclient\node_modules\discord-rpc\src\client.js:139:12)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:8936) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

My ClientID is absolutely correct, and I couldn't figure out why it isnt working. Any help will be appreciated.

Try asking for help in the https://github.com/discordjs/RPC issues.
This deprecated library is just the native C++ implementation.