-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added Discord Rich Presence (disabled by default, can be toggled fr…
…om the settings). - Now uses winston for logging. - Now kills Stremio Service when the app is closed.
- Loading branch information
1 parent
d0e5499
commit f8fd70d
Showing
11 changed files
with
980 additions
and
429 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import DiscordRPC from 'discord-rpc'; | ||
import logger from './logger'; | ||
|
||
class DiscordPresence { | ||
public rpc:any; | ||
constructor() { | ||
try { | ||
const clientId = '1200186750727893164'; | ||
DiscordRPC.register(clientId); | ||
|
||
this.rpc = new DiscordRPC.Client({ transport: 'ipc' }); | ||
this.rpc.on('ready', () => { | ||
logger.info('Connected to DiscordRPC.'); | ||
this.updateActivity({ | ||
details: "Main Menu", | ||
largeImageKey: '1024stremio', | ||
largeImageText: 'Stremio Enhanced', | ||
smallImageKey: "menuburger", | ||
smallImageText: "Main Menu", | ||
instance: false, | ||
}) | ||
}); | ||
|
||
this.rpc.login({ clientId }).catch(logger.error); | ||
}catch(e) { | ||
logger.error(e); | ||
} | ||
} | ||
|
||
public updateActivity(newActivity: Activity) { | ||
try { | ||
this.rpc.setActivity(newActivity); | ||
}catch(e) { | ||
logger.error(e) | ||
} | ||
} | ||
|
||
public stopActivity() { | ||
logger.info('Clearing DiscordRPC.'); | ||
this.rpc.clearActivity(); | ||
} | ||
} | ||
|
||
interface Activity { | ||
details: string, | ||
state?: string, | ||
startTimestamp?: Date, | ||
endTimestamp?: Date, | ||
largeImageKey: string, | ||
largeImageText?: string, | ||
smallImageKey?: string, | ||
smallImageText?: string, | ||
partySize?: number, | ||
partyMax?: number, | ||
instance: boolean | ||
} | ||
|
||
export default DiscordPresence; |
Oops, something went wrong.