Maybe? Can't build

This commit is contained in:
3top1a 2024-10-16 20:37:47 +02:00
parent 6e59d59a1d
commit 1a0c15e17f
5 changed files with 60 additions and 30 deletions

33
package-lock.json generated
View File

@ -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"
},

View File

@ -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",

View File

@ -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", () => {

39
src/types/discord-rpc.d.ts vendored Normal file
View File

@ -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<void>;
setActivity(presence: Presence): Promise<void>;
clearActivity(): Promise<void>;
destroy(): Promise<void>;
}
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
};
}

View File

@ -11,6 +11,7 @@
"resolveJsonModule": true,
"esModuleInterop": true,
"baseUrl": ".",
"allowSyntheticDefaultImports": true,
"paths": {
"*": ["node_modules/*"]
}