discord / discord-rpc

https://discordapp.com/developers
MIT License
1.06k stars 330 forks source link

Error: Could not connect #365

Open XqMine opened 2 years ago

XqMine commented 2 years ago

hi, i have a problem, when i run my project i get this error image my code:

const clientId = '973698144086945872';
const DiscordRPC = require('discord-rpc');
const RPC = new DiscordRPC.Client({ transport: 'ipc'});

DiscordRPC.register(clientId);

async function setActivity() {
    if (!RPC) return;
    RPC.setActivity({

        startTimestamp: Date.now(),
        endTimestamp: Date.now(),
        largeImageKey: 'anya',
        largeImageText: `Anya forger`,
        smallImageKey: `midorya`,
        smallImageText: `zWmin`,
        instance: true,

    });
};

RPC.on('ready', async () => {
    setActivity();

    setInterval(() => {
        setActivity();
    }, 15 * 1000);
});

RPC.login({ clientId }).catch(err => console.error(err));

i hope someone can help me

Lachee commented 2 years ago

make sure the discord client is running on the same computer. Additionally, ask the DiscordRPC.js library.