2021-02-26 12:27:32 +00:00
|
|
|
package;
|
|
|
|
|
2021-02-26 12:52:40 +00:00
|
|
|
import Sys.sleep;
|
2021-02-26 12:27:32 +00:00
|
|
|
import discord_rpc.DiscordRpc;
|
|
|
|
|
|
|
|
using StringTools;
|
|
|
|
|
|
|
|
class DiscordClient
|
|
|
|
{
|
|
|
|
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();
|
2021-02-26 12:52:40 +00:00
|
|
|
sleep(2);
|
2021-02-26 13:23:03 +00:00
|
|
|
//trace("Discord Client Update");
|
2021-02-26 12:27:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2021-02-27 19:58:07 +00:00
|
|
|
public static function changePresence(details:String, state:Null<String>, ?smallImageKey : String, ?startTimestamp: Int, ?endTimestamp: Int)
|
2021-02-26 12:27:32 +00:00
|
|
|
{
|
|
|
|
DiscordRpc.presence({
|
|
|
|
details: details,
|
|
|
|
state: state,
|
|
|
|
largeImageKey: 'icon',
|
2021-02-27 19:58:07 +00:00
|
|
|
largeImageText: "Friday Night Funkin'",
|
|
|
|
smallImageKey : smallImageKey,
|
|
|
|
startTimestamp : startTimestamp,
|
|
|
|
endTimestamp : endTimestamp
|
2021-02-26 12:27:32 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|