mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-11-14 09:09:57 -08:00
ce86840a87
Removed the old workaround logic for queueing archives for extraction. Removed the old forge callback (this was replaced a while ago). Fixed a typo in _parseDistroModules (getType). Use discordrpc straight from the repository. The author has refused to push the bugfix for nearly a month. Fix timestamp issue on discord rich presence. Dependency upgrades.
48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
// Work in progress
|
|
const logger = require('./loggerutil')('%c[DiscordWrapper]', 'color: #7289da; font-weight: bold')
|
|
|
|
const {Client} = require('discord-rpc')
|
|
|
|
let client
|
|
let activity
|
|
|
|
exports.initRPC = function(genSettings, servSettings, initialDetails = 'Waiting for Client..'){
|
|
client = new Client({ transport: 'ipc' })
|
|
|
|
activity = {
|
|
details: initialDetails,
|
|
state: 'Server: ' + servSettings.shortId,
|
|
largeImageKey: servSettings.largeImageKey,
|
|
largeImageText: servSettings.largeImageText,
|
|
smallImageKey: genSettings.smallImageKey,
|
|
smallImageText: genSettings.smallImageText,
|
|
startTimestamp: new Date().getTime(),
|
|
instance: false
|
|
}
|
|
|
|
client.on('ready', () => {
|
|
logger.log('Discord RPC Connected')
|
|
client.setActivity(activity)
|
|
})
|
|
|
|
client.login({clientId: genSettings.clientId}).catch(error => {
|
|
if(error.message.includes('ENOENT')) {
|
|
logger.log('Unable to initialize Discord Rich Presence, no client detected.')
|
|
} else {
|
|
logger.log('Unable to initialize Discord Rich Presence: ' + error.message, error)
|
|
}
|
|
})
|
|
}
|
|
|
|
exports.updateDetails = function(details){
|
|
activity.details = details
|
|
client.setActivity(activity)
|
|
}
|
|
|
|
exports.shutdownRPC = function(){
|
|
if(!client) return
|
|
client.clearActivity()
|
|
client.destroy()
|
|
client = null
|
|
activity = null
|
|
} |