const RPC = require("discord-rpc") class DiscordRPC { constructor() { readonly: this.activity = { details: "Officiel | Solva x Alcaz", timestamps : { start: Date.now() }, assets: { large_image: "rpc_catboat_large", large_text: "CatBoat Launcher", small_image : "alflamme_comm_legoshi", small_text: "by TheAlfiTeam", }, buttons: [ { "label": "Discord", "url": "https://discord.gg/catboat" }, { "label": "Download Launcher", "url": "https://catboat.thealfigame.fr" } ], instance: true } readonly: this.client = new RPC.Client({ transport: "ipc" }) this.isEnabled = false } startRichPresence() { if (!this.isEnabled) { this.client.on("ready", () => { this.client.request("SET_ACTIVITY", { pid: process.pid, activity: this.activity }) console.log("The Discord Rich Presence has been set successfully.") }) this.client.login({ clientId: "1259291027148115988" }).catch(e => { console.log("Silent client detected: the activity status has been disabled.") console.log(e) this.isEnabled = false }).then(r => this.isEnabled = true) .catch(err => console.log(err)) } } stopRichPresence() { if (this.isEnabled) { this.client.destroy() this.isEnabled = false } } } module.exports = new DiscordRPC()