This repository has been archived by the owner on Jul 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a19a31
commit e80d1f2
Showing
7 changed files
with
129 additions
and
27 deletions.
There are no files selected for viewing
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
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,92 @@ | ||
package; | ||
|
||
import Sys.sleep; | ||
|
||
using StringTools; | ||
|
||
#if DISCORD_ALLOWED | ||
import discord_rpc.DiscordRpc; | ||
#end | ||
|
||
class DiscordClient | ||
{ | ||
#if DISCORD_ALLOWED | ||
public function new() | ||
{ | ||
trace("Discord Client starting..."); | ||
DiscordRpc.start({ | ||
clientID: "814588678700924999", | ||
onReady: onReady, | ||
onError: onError, | ||
onDisconnected: onDisconnected | ||
}); | ||
trace("Discord Client started."); | ||
|
||
while (true) | ||
{ | ||
DiscordRpc.process(); | ||
sleep(2); | ||
// trace("Discord Client Update"); | ||
} | ||
|
||
DiscordRpc.shutdown(); | ||
} | ||
|
||
public static function shutdown() | ||
{ | ||
DiscordRpc.shutdown(); | ||
} | ||
|
||
static function onReady() | ||
{ | ||
DiscordRpc.presence({ | ||
details: "In the Menus", | ||
state: null, | ||
largeImageKey: 'icon', | ||
largeImageText: "Friday Night Funkin'" | ||
}); | ||
} | ||
|
||
static function onError(_code:Int, _message:String) | ||
{ | ||
trace('Error! $_code : $_message'); | ||
} | ||
|
||
static function onDisconnected(_code:Int, _message:String) | ||
{ | ||
trace('Disconnected! $_code : $_message'); | ||
} | ||
|
||
public static function initialize() | ||
{ | ||
var DiscordDaemon = sys.thread.Thread.create(() -> | ||
{ | ||
new DiscordClient(); | ||
}); | ||
trace("Discord Client initialized"); | ||
} | ||
|
||
public static function changePresence(details:String, state:Null<String>, ?smallImageKey:String, ?hasStartTimestamp:Bool, ?endTimestamp:Float) | ||
{ | ||
var startTimestamp:Float = if (hasStartTimestamp) Date.now().getTime() else 0; | ||
|
||
if (endTimestamp > 0) | ||
{ | ||
endTimestamp = startTimestamp + endTimestamp; | ||
} | ||
|
||
DiscordRpc.presence({ | ||
details: details, | ||
state: state, | ||
largeImageKey: 'icon', | ||
largeImageText: "Friday Night Funkin'", | ||
smallImageKey: smallImageKey, | ||
// Obtained times are in milliseconds so they are divided so Discord can use it | ||
startTimestamp: Std.int(startTimestamp / 1000), | ||
endTimestamp: Std.int(endTimestamp / 1000) | ||
}); | ||
|
||
// trace('Discord RPC Updated. Arguments: $details, $state, $smallImageKey, $hasStartTimestamp, $endTimestamp'); | ||
} | ||
#end | ||
} |
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
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