From 1a0c15e17fd79202fd4144077ae8a3a28d464c11 Mon Sep 17 00:00:00 2001 From: 3top1a <3top1a.official@gmail.com> Date: Wed, 16 Oct 2024 20:37:47 +0200 Subject: [PATCH] Maybe? Can't build --- package-lock.json | 33 +++++++++++--------------------- package.json | 5 ++--- src/scripts/discord.ts | 12 +++++++----- src/types/discord-rpc.d.ts | 39 ++++++++++++++++++++++++++++++++++++++ tsconfig.json | 1 + 5 files changed, 60 insertions(+), 30 deletions(-) create mode 100644 src/types/discord-rpc.d.ts diff --git a/package-lock.json b/package-lock.json index 67ba00e..b19fbb5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@types/swagger-jsdoc": "^6.0.4", "axios": "^1.7.7", "cors": "^2.8.5", - "discord-rpc": "^4.0.1", + "discord-rpc": "github:sKiLdUsT/RPC#types", "electron-store": "^8.2.0", "express": "^4.21.1", "hotkeys-js": "^3.13.7", @@ -25,7 +25,6 @@ "devDependencies": { "@mastermindzh/prettier-config": "^1.0.0", "@types/cors": "^2.8.17", - "@types/discord-rpc": "^4.0.8", "@types/express": "^4.17.21", "@types/node": "^20.14.10", "@types/request": "^2.48.12", @@ -33,7 +32,7 @@ "@typescript-eslint/eslint-plugin": "^7.16.0", "@typescript-eslint/parser": "^7.15.0", "copyfiles": "^2.4.1", - "electron": "git+https://github.com/castlabs/electron-releases#v31.1.0+wvcus", + "electron": "git+https://github.com/castlabs/electron-releases#v33.1.0+wvcus", "electron-builder": "~24.9.4", "eslint": "^8.57.0", "js-yaml": "^4.1.0", @@ -1230,21 +1229,6 @@ "@types/ms": "*" } }, - "node_modules/@types/discord-rpc": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/@types/discord-rpc/-/discord-rpc-4.0.8.tgz", - "integrity": "sha512-1tZf217Natkj+TziNXRRLwNmdm5GNa1bnrQr8VWowquo/Su5hMjdhobj8URxW1COMk2da28XCU1ahsYCAlxirA==", - "dev": true, - "dependencies": { - "@types/events": "*" - } - }, - "node_modules/@types/events": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.3.tgz", - "integrity": "sha512-trOc4AAUThEz9hapPtSd7wf5tiQKvTtu5b371UxXdTuqzIh0ArcRspRP0i0Viu+LXstIQ1z96t1nsPxT9ol01g==", - "dev": true - }, "node_modules/@types/express": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.21.tgz", @@ -3382,8 +3366,8 @@ }, "node_modules/discord-rpc": { "version": "4.0.1", - "resolved": "https://registry.npmjs.org/discord-rpc/-/discord-rpc-4.0.1.tgz", - "integrity": "sha512-HOvHpbq5STRZJjQIBzwoKnQ0jHplbEWFWlPDwXXKm/bILh4nzjcg7mNqll0UY7RsjFoaXA7e/oYb/4lvpda2zA==", + "resolved": "git+ssh://git@github.com/sKiLdUsT/RPC.git#1c5b6842fa586a1b7b339a50fa5ec1c4cf6c8867", + "license": "MIT", "dependencies": { "node-fetch": "^2.6.1", "ws": "^7.3.1" @@ -6152,6 +6136,7 @@ "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "license": "MIT", "dependencies": { "whatwg-url": "^5.0.0" }, @@ -8532,7 +8517,8 @@ "node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "license": "MIT" }, "node_modules/truncate-utf8-bytes": { "version": "1.0.2", @@ -8819,12 +8805,14 @@ "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "license": "BSD-2-Clause" }, "node_modules/whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "license": "MIT", "dependencies": { "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" @@ -8903,6 +8891,7 @@ "version": "7.5.10", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", + "license": "MIT", "engines": { "node": ">=8.3.0" }, diff --git a/package.json b/package.json index 2aa8b87..a79097b 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@types/swagger-jsdoc": "^6.0.4", "axios": "^1.7.7", "cors": "^2.8.5", - "discord-rpc": "^4.0.1", + "discord-rpc": "github:sKiLdUsT/RPC#types", "electron-store": "^8.2.0", "express": "^4.21.1", "hotkeys-js": "^3.13.7", @@ -56,7 +56,6 @@ "devDependencies": { "@mastermindzh/prettier-config": "^1.0.0", "@types/cors": "^2.8.17", - "@types/discord-rpc": "^4.0.8", "@types/express": "^4.17.21", "@types/node": "^20.14.10", "@types/request": "^2.48.12", @@ -64,7 +63,7 @@ "@typescript-eslint/eslint-plugin": "^7.16.0", "@typescript-eslint/parser": "^7.15.0", "copyfiles": "^2.4.1", - "electron": "git+https://github.com/castlabs/electron-releases#v31.1.0+wvcus", + "electron": "git+https://github.com/castlabs/electron-releases#v32.0.0+wvcus", "electron-builder": "~24.9.4", "eslint": "^8.57.0", "js-yaml": "^4.1.0", diff --git a/src/scripts/discord.ts b/src/scripts/discord.ts index 4a162a6..6fc06e2 100644 --- a/src/scripts/discord.ts +++ b/src/scripts/discord.ts @@ -1,4 +1,4 @@ -import { Client, Presence } from "discord-rpc"; +import * as DRPC from "discord-rpc"; import { app, ipcMain } from "electron"; import { globalEvents } from "../constants/globalEvents"; import { settings } from "../constants/settings"; @@ -10,7 +10,7 @@ import { settingsStore } from "./settings"; const clientId = "833617820704440341"; -export let rpc: Client; +export let rpc: DRPC.Client; const observer = () => { if (rpc) { @@ -33,8 +33,10 @@ const updateActivity = () => { } }; -const getActivity = (): Presence => { - const presence: Presence = { ...defaultPresence }; +const getActivity = (): DRPC.Presence => { + const presence: DRPC.Presence = { ...defaultPresence }; + + presence.type = DRPC.ActivityTypes.LISTENING if (mediaInfo.status === MediaStatus.paused) { presence.details = @@ -110,7 +112,7 @@ const getActivity = (): Presence => { * Set up the discord rpc and listen on globalEvents.updateInfo */ export const initRPC = () => { - rpc = new Client({ transport: "ipc" }); + rpc = new DRPC.Client({ transport: "ipc" }); rpc.login({ clientId }).then( () => { rpc.on("ready", () => { diff --git a/src/types/discord-rpc.d.ts b/src/types/discord-rpc.d.ts new file mode 100644 index 0000000..e66c00c --- /dev/null +++ b/src/types/discord-rpc.d.ts @@ -0,0 +1,39 @@ +declare module 'discord-rpc' { + export class Client { + constructor(options: { transport: 'ipc' }); + on(event: string, listener: (...args: any[]) => void): this; + login(options: { clientId: string }): Promise; + setActivity(presence: Presence): Promise; + clearActivity(): Promise; + destroy(): Promise; + } + + export interface Presence { + state?: string; + details?: string; + startTimestamp?: number; + endTimestamp?: number; + largeImageKey?: string; + largeImageText?: string; + smallImageKey?: string; + smallImageText?: string; + partyId?: string; + partySize?: number; + partyMax?: number; + matchSecret?: string; + spectateSecret?: string; + joinSecret?: string; + instance?: boolean; + type?: number; + buttons?: Array<{ label: string; url: string }>; + } + + export const ActivityTypes: { + PLAYING: 0, + STREAMING: 1, + LISTENING: 2, + WATCHING: 3, + CUSTOM: 4, + COMPETING: 5 + }; +} diff --git a/tsconfig.json b/tsconfig.json index 89364cb..5440346 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,6 +11,7 @@ "resolveJsonModule": true, "esModuleInterop": true, "baseUrl": ".", + "allowSyntheticDefaultImports": true, "paths": { "*": ["node_modules/*"] }