Objectif : J'essaie d'enrichir la présence de la discorde.
Code :
const RPC = require("discord-rpc");
const rpc = new RPC.Client({
transport: 'ipc',
});
const chalk = require('chalk');
const settings = require('./settings.json');
const details = settings.details;
const state = settings.state;
const LIK = settings.largeImageKey;
const LIT = settings.largeImageText;
const SIK = settings.smallImageKey;
const SIT = settings.smallImageText;
const ID = settings.clientID;
rpc.on("ready", () => {
rpc.setActivity({
details: `${details}`,
state: `${state}`,
startTimestamp: new Date(),
largeImageKey: `${LIK}`,
largeImageText: `${LIT}`,
smallImageKey: `${SIK}`,
smallImageText: `${SIT}`
});
console.log(chalk.green("Rich Prescence is on: " + rpc.user.username))
});
rpc.login({
clientId: `${ID}`,
})
Erreur :
(node:2128) UnhandledPromiseRejectionWarning: Error: Could not connect
at Socket.onerror (C:\Users\Familia\OneDrive\Documents\Other Stuff\Visual Studio code\Discord Bots\Testing\Art Prescence\node_modules\discord-rpc\src\transports\ipc.js:32:16)
at Object.onceWrapper (events.js:422:26)
at Socket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:2128) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2128) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Il indique qu'il ne se connecte pas, bien qu'il ait fait tout ce qu'il fallait. Je ne sais pas comment résoudre ce problème. De l'aide serait appréciée.
Editer : Ayant remarqué que je n'avais pas inclus les sites web, j'ai procédé comme suit :
const RPC = require("discord-rpc");
const browser = typeof window !== 'undefined';
const rpc = new RPC.Client({ transport: browser ? "websocket" : "ipc"});
La même erreur s'est produite