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

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
};
}