2020-10-10 20:17:48 -05:00
|
|
|
print("Loading discord RPC...")
|
|
|
|
DiscordRPC = {
|
|
|
|
loaded = false
|
|
|
|
}
|
|
|
|
local success, RPC = pcall(require, "libs.discordRPC")
|
|
|
|
if success then
|
|
|
|
DiscordRPC.loaded = true
|
|
|
|
DiscordRPC.appId = "599778517789573120"
|
|
|
|
|
|
|
|
function RPC.ready(userId, username, discriminator, avatar)
|
|
|
|
print(string.format("Discord: ready (%s, %s, %s, %s)", userId, username, discriminator, avatar))
|
|
|
|
end
|
|
|
|
|
|
|
|
function RPC.disconnected(errorCode, message)
|
|
|
|
print(string.format("Discord: disconnected (%d: %s)", errorCode, message))
|
|
|
|
end
|
|
|
|
|
|
|
|
function RPC.errored(errorCode, message)
|
|
|
|
print(string.format("Discord: error (%d: %s)", errorCode, message))
|
|
|
|
end
|
|
|
|
|
|
|
|
function RPC.joinGame(joinSecret)
|
|
|
|
print(string.format("Discord: join (%s)", joinSecret))
|
|
|
|
end
|
|
|
|
|
|
|
|
function RPC.spectateGame(spectateSecret)
|
|
|
|
print(string.format("Discord: spectate (%s)", spectateSecret))
|
|
|
|
end
|
|
|
|
|
|
|
|
function RPC.joinRequest(userId, username, discriminator, avatar)
|
|
|
|
print(string.format("Discord: join request (%s, %s, %s, %s)", userId, username, discriminator, avatar))
|
|
|
|
RPC.respond(userId, "yes")
|
|
|
|
end
|
|
|
|
|
|
|
|
RPC.initialize(DiscordRPC.appId, true)
|
|
|
|
local now = os.time(os.date("*t"))
|
|
|
|
|
|
|
|
DiscordRPC.RPC = RPC
|
|
|
|
print("DiscordRPC successfully loaded.")
|
|
|
|
else
|
|
|
|
print("DiscordRPC failed to load!")
|
|
|
|
print(RPC)
|
|
|
|
end
|
|
|
|
|
2020-10-12 18:39:13 -05:00
|
|
|
DiscordRPC.presence = {
|
|
|
|
startTimestamp = now,
|
|
|
|
details = "Loading game...",
|
|
|
|
state = "",
|
|
|
|
largeImageKey = "icon2",
|
|
|
|
largeImageText = "Original game by Joe Zeng",
|
|
|
|
smallImageKey = "",
|
|
|
|
smallImageText = ""
|
|
|
|
}
|
|
|
|
|
2020-10-10 20:17:48 -05:00
|
|
|
function DiscordRPC:update(newstuff)
|
2020-10-12 18:39:13 -05:00
|
|
|
for k, v in pairs(newstuff) do self.presence[k] = v end
|
|
|
|
if self.loaded then self.RPC.updatePresence(self.presence) end
|
|
|
|
end
|