-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.lua
58 lines (47 loc) · 1.66 KB
/
main.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
local discordRPC = require("discordRPC")
local appId = require("applicationId")
function discordRPC.ready(userId, username, discriminator, avatar)
print(string.format("Discord: ready (%s, %s, %s, %s)", userId, username, discriminator, avatar))
end
function discordRPC.disconnected(errorCode, message)
print(string.format("Discord: disconnected (%d: %s)", errorCode, message))
end
function discordRPC.errored(errorCode, message)
print(string.format("Discord: error (%d: %s)", errorCode, message))
end
function discordRPC.joinGame(joinSecret)
print(string.format("Discord: join (%s)", joinSecret))
end
function discordRPC.spectateGame(spectateSecret)
print(string.format("Discord: spectate (%s)", spectateSecret))
end
function discordRPC.joinRequest(userId, username, discriminator, avatar)
print(string.format("Discord: join request (%s, %s, %s, %s)", userId, username, discriminator, avatar))
discordRPC.respond(userId, "yes")
end
function love.load()
discordRPC.initialize(appId, true)
local now = os.time(os.date("*t"))
presence = {
state = "Looking to Play",
details = "1v1 (Ranked)",
startTimestamp = now,
endTimestamp = now + 60,
partyId = "party id",
partyMax = 2,
matchSecret = "match secret",
joinSecret = "join secret",
spectateSecret = "spectate secret",
}
nextPresenceUpdate = 0
end
function love.update()
if nextPresenceUpdate < love.timer.getTime() then
discordRPC.updatePresence(presence)
nextPresenceUpdate = love.timer.getTime() + 2.0
end
discordRPC.runCallbacks()
end
function love.quit()
discordRPC.shutdown()
end