mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-12-19 16:33:04 +03:00
Merge branch 'main' of Maroxy/an-ordinary-launcher into main
This commit is contained in:
commit
399e04ea2c
3 changed files with 17 additions and 15 deletions
|
@ -38,6 +38,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/discord-rpc": "^4.0.0",
|
||||||
"electron": "^14.0.0",
|
"electron": "^14.0.0",
|
||||||
"electron-builder": "^22.13.1",
|
"electron-builder": "^22.13.1",
|
||||||
"sass": "^1.41.0",
|
"sass": "^1.41.0",
|
||||||
|
|
|
@ -40,8 +40,8 @@ $(() => {
|
||||||
|
|
||||||
ipcRenderer.on('rpc-toggle', () => {
|
ipcRenderer.on('rpc-toggle', () => {
|
||||||
DiscordRPC.isActive() ?
|
DiscordRPC.isActive() ?
|
||||||
DiscordRPC.init() :
|
DiscordRPC.close() :
|
||||||
DiscordRPC.close();
|
DiscordRPC.init();
|
||||||
});
|
});
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
|
@ -208,7 +208,8 @@ $(() => {
|
||||||
DiscordRPC.setActivity({
|
DiscordRPC.setActivity({
|
||||||
details: 'In-Game',
|
details: 'In-Game',
|
||||||
largeImageKey: 'game',
|
largeImageKey: 'game',
|
||||||
largeImageText: 'An Anime Game Launcher'
|
largeImageText: 'An Anime Game Launcher',
|
||||||
|
startTimestamp: new Date().setDate(new Date().getDate())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const discordRpc = require('discord-rpc');
|
import discordRpc, { Client, Presence } from 'discord-rpc';
|
||||||
|
|
||||||
export class DiscordRPC
|
export class DiscordRPC
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@ export class DiscordRPC
|
||||||
|
|
||||||
public static init ()
|
public static init ()
|
||||||
{
|
{
|
||||||
this.rpc = new discordRpc.Client({ transport: 'ipc' });
|
this.rpc = new discordRpc.Client({ transport: 'ipc' }) as Client;
|
||||||
|
|
||||||
this.rpc.login({ clientId: this.clientId }).catch(console.error);
|
this.rpc.login({ clientId: this.clientId }).catch(console.error);
|
||||||
|
|
||||||
|
@ -16,18 +16,18 @@ export class DiscordRPC
|
||||||
this.rpc.setActivity({
|
this.rpc.setActivity({
|
||||||
details: 'Preparing to launch',
|
details: 'Preparing to launch',
|
||||||
largeImageKey: 'launcher',
|
largeImageKey: 'launcher',
|
||||||
largeImageText: 'An Anime Game Launcher',
|
largeImageText: 'An Anime Game Launcher'
|
||||||
instance: false
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static setActivity (activity: any): void
|
public static setActivity (activity: Presence): void
|
||||||
{
|
{
|
||||||
this.rpc?.setActivity({
|
this.rpc.setActivity({
|
||||||
startTimestamp: parseInt(new Date().setDate(new Date().getDate()).toString()),
|
...activity,
|
||||||
instance: false,
|
...{
|
||||||
...activity
|
instance: false
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,9 +38,9 @@ export class DiscordRPC
|
||||||
|
|
||||||
public static close (): void
|
public static close (): void
|
||||||
{
|
{
|
||||||
this.rpc?.clearActivity();
|
this.rpc.clearActivity();
|
||||||
this.rpc?.destroy();
|
this.rpc.destroy();
|
||||||
|
|
||||||
this.rpc = null;
|
this.rpc = null as any;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue