-
Notifications
You must be signed in to change notification settings - Fork 81
/
PresenceBuilder.kt
47 lines (37 loc) · 1.5 KB
/
PresenceBuilder.kt
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
package dev.kord.gateway.builder
import dev.kord.common.annotation.KordDsl
import dev.kord.common.entity.ActivityType
import dev.kord.common.entity.DiscordBotActivity
import dev.kord.common.entity.PresenceStatus
import dev.kord.common.entity.optional.Optional
import dev.kord.gateway.DiscordPresence
import dev.kord.gateway.UpdateStatus
import kotlinx.datetime.Instant
@KordDsl
public class PresenceBuilder {
private var game: DiscordBotActivity? = null
public var status: PresenceStatus = PresenceStatus.Online
public var afk: Boolean = false
public var since: Instant? = null
public fun playing(name: String) {
game = DiscordBotActivity(name, ActivityType.Game)
}
public fun listening(name: String) {
game = DiscordBotActivity(name, ActivityType.Listening)
}
public fun streaming(name: String, url: String) {
game = DiscordBotActivity(name, ActivityType.Streaming, url = Optional(url))
}
public fun watching(name: String) {
game = DiscordBotActivity(name, ActivityType.Watching)
}
public fun competing(name: String) {
game = DiscordBotActivity(name, ActivityType.Competing)
}
public fun custom(state: String) {
game = DiscordBotActivity(name = "Custom Status", state = Optional(state), type = ActivityType.Custom)
}
}
public fun toUpdateStatus(): UpdateStatus = UpdateStatus(since, listOfNotNull(game), status, afk)
public fun toPresence(): DiscordPresence = DiscordPresence(status, afk, since, game)
}