Skip to content

Commit

Permalink
[discord-rich-presence] Add more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgio committed Feb 12, 2021
1 parent 85a14e8 commit ffad7d8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion discord-rich-presence/discord-rich-presence.js
Expand Up @@ -9,10 +9,12 @@ const drpcPackage = 'club.minnced.discord.rpc.';
let presence;
let lib;

// Updates the status
function update() {
if(lib && presence) lib.Discord_UpdatePresence(presence);
}

// Changes presence details depending on 'Show file' setting value and current tab file
function changePresenceDetails(tab) {
if(!getConfig().getBoolean('show_file')) {
presence.details = '';
Expand All @@ -28,10 +30,12 @@ function changePresenceDetails(tab) {
}
}

// Changes presence start timestamp depending on 'Show elapsed time' setting value
function changePresenceTimestamp() {
presence.startTimestamp = getConfig().getBoolean('show_elapsed_time') ? java.lang.System.currentTimeMillis() : 0;
}

// Initializes rich presence
function initRPC() {
// Loading library file
// Not using loadJar since it causes errors when working with DLL files as the library internally does
Expand Down Expand Up @@ -61,6 +65,7 @@ function initRPC() {
setInterval(() => lib.Discord_RunCallbacks(), 2000);
}

// Initializes the translation schemes
function initTranslations() {
translationMap = {
'editing': {
Expand Down Expand Up @@ -89,6 +94,7 @@ function initTranslations() {
}
}

// Loads config.yml
function initConfig() {
// Creating the configuration
createConfig({
Expand All @@ -106,7 +112,6 @@ function initConfig() {

// Handling changes when the user modifies the 'Show elapsed time' setting
addConfigListener('show_elapsed_time', () => {
const value = getConfig().getBoolean('show_elapsed_time');
changePresenceTimestamp();
update();
});
Expand Down

0 comments on commit ffad7d8

Please sign in to comment.