Reputation: 163
I am trying to setup Discord RPC. For it, I registered a new application and copied the client ID. Then I am using this code:
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);
console.log(discordClient.application.name);
console.log(discordClient.user.username);
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: "871730144836976650"}).catch(console.error)
})();
But this gives me the following error:
Authed for user { id: '771601176155783198',
username: 'AwesomeSam',
discriminator: '7985',
avatar: '93d3fd4fb9fd0921830d69e07a248036',
bot: false,
flags: 176,
premium_type: 1 }
(node:6664) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'name' of null
at RPCClient.discordClient.on (D:\kirkaclient\src\features\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)
Upvotes: 0
Views: 200
Reputation: 11
Well, it is as it says.
Cannot read property 'name' of null
It seems that the property "discordClient.application" in line 9 is null, so it could not read a "name" value of null.
I'm not into discord-rpc, I do prefer discord.js, so I can't come up with a solution for this.
You should try debugging it with console.log(discordClient)
Upvotes: 1