diff --git a/Sources/SwordRPC/Types/Enums.swift b/Sources/SwordRPC/Types/Enums.swift index a76947d..c4bfd2f 100644 --- a/Sources/SwordRPC/Types/Enums.swift +++ b/Sources/SwordRPC/Types/Enums.swift @@ -50,3 +50,14 @@ public enum ActivityType: Int, Codable { /// "Competing in Arena World Champions" case competing = 5 } + +/// The displayed status types. +/// https://discord.com/developers/docs/events/gateway-events#activity-object-status-display-types +public enum StatusDisplayType: Int, Codable { + /// "Playing " + case name = 0 + /// "Playing " + case state = 1 + /// "Playing
" + case details = 2 +} diff --git a/Sources/SwordRPC/Types/RichPresence.swift b/Sources/SwordRPC/Types/RichPresence.swift index 20f2a49..bfda432 100644 --- a/Sources/SwordRPC/Types/RichPresence.swift +++ b/Sources/SwordRPC/Types/RichPresence.swift @@ -11,13 +11,31 @@ import Foundation public struct RichPresence: Encodable { public var assets = Assets() public var details = "" + public var detailsUrl: String? public var instance = true public var party = Party() public var secrets: Secrets? public var state = "" + public var stateUrl: String? public var timestamps = Timestamps() public var buttons: [Button]? public var type: ActivityType? + public var statusDisplayType: StatusDisplayType? + + enum CodingKeys: String, CodingKey { + case assets + case details + case detailsUrl = "details_url" + case instance + case party + case secrets + case state + case stateUrl = "state_url" + case timestamps + case buttons + case type + case statusDisplayType = "status_display_type" + } public init() {} } diff --git a/Tests/SwordRPCTests/SwordRPCTests.swift b/Tests/SwordRPCTests/SwordRPCTests.swift index 5db0efe..3c4dbdd 100644 --- a/Tests/SwordRPCTests/SwordRPCTests.swift +++ b/Tests/SwordRPCTests/SwordRPCTests.swift @@ -27,13 +27,18 @@ class SwordRPC_DiscordTests: XCTestCase, SwordRPCDelegate { // Set to listening status presence.type = .listening - // Assign state & details. - presence.state = "Love Me Again" - presence.details = "John Newman – Tribute" + // Assign details & state. + presence.details = "Love Me Again" + presence.detailsUrl = "https://music.apple.com/us/album/love-me-again/1440813192?i=1440813380" + presence.state = "John Newman" + presence.stateUrl = "https://music.apple.com/us/artist/john-newman/649230577" + + // Show song title instead of "Music." + presence.statusDisplayType = .details // Assign image properties. presence.assets.largeImage = "big_sur_logo" - presence.assets.largeText = "Apple Music" + presence.assets.largeText = "Tribute" // This is used as the album text in the "Listening" status. presence.assets.smallImage = "play" presence.assets.smallText = "Playing"