From 380dbbc49e2c81d492ae697c54fa7b4e12b3289d Mon Sep 17 00:00:00 2001 From: Deltaion Lee <32529306+MCMi460@users.noreply.github.com> Date: Sun, 17 Aug 2025 11:48:56 -0400 Subject: [PATCH 1/2] `status_display_type`, `details_url`, `state_url` --- Sources/SwordRPC/Types/Enums.swift | 11 +++++++++++ Sources/SwordRPC/Types/RichPresence.swift | 3 +++ Tests/SwordRPCTests/SwordRPCTests.swift | 13 +++++++++---- 3 files changed, 23 insertions(+), 4 deletions(-) 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..ad42f05 100644 --- a/Sources/SwordRPC/Types/RichPresence.swift +++ b/Sources/SwordRPC/Types/RichPresence.swift @@ -11,13 +11,16 @@ import Foundation public struct RichPresence: Encodable { public var assets = Assets() public var details = "" + public var details_url: String? public var instance = true public var party = Party() public var secrets: Secrets? public var state = "" + public var state_url: String? public var timestamps = Timestamps() public var buttons: [Button]? public var type: ActivityType? + public var status_display_type: StatusDisplayType? public init() {} } diff --git a/Tests/SwordRPCTests/SwordRPCTests.swift b/Tests/SwordRPCTests/SwordRPCTests.swift index 5db0efe..0789f81 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.details_url = "https://music.apple.com/us/album/love-me-again/1440813192?i=1440813380" + presence.state = "John Newman" + presence.state_url = "https://music.apple.com/us/artist/john-newman/649230577" + + // Show song title instead of "Music." + presence.status_display_type = .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" From 862f44d5a05bcdba551f2b4f93db1174306fd331 Mon Sep 17 00:00:00 2001 From: Deltaion Lee <32529306+MCMi460@users.noreply.github.com> Date: Sun, 17 Aug 2025 13:22:49 -0400 Subject: [PATCH 2/2] snake_case to camelCase --- Sources/SwordRPC/Types/RichPresence.swift | 21 ++++++++++++++++++--- Tests/SwordRPCTests/SwordRPCTests.swift | 6 +++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Sources/SwordRPC/Types/RichPresence.swift b/Sources/SwordRPC/Types/RichPresence.swift index ad42f05..bfda432 100644 --- a/Sources/SwordRPC/Types/RichPresence.swift +++ b/Sources/SwordRPC/Types/RichPresence.swift @@ -11,16 +11,31 @@ import Foundation public struct RichPresence: Encodable { public var assets = Assets() public var details = "" - public var details_url: String? + public var detailsUrl: String? public var instance = true public var party = Party() public var secrets: Secrets? public var state = "" - public var state_url: String? + public var stateUrl: String? public var timestamps = Timestamps() public var buttons: [Button]? public var type: ActivityType? - public var status_display_type: StatusDisplayType? + 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 0789f81..3c4dbdd 100644 --- a/Tests/SwordRPCTests/SwordRPCTests.swift +++ b/Tests/SwordRPCTests/SwordRPCTests.swift @@ -29,12 +29,12 @@ class SwordRPC_DiscordTests: XCTestCase, SwordRPCDelegate { // Assign details & state. presence.details = "Love Me Again" - presence.details_url = "https://music.apple.com/us/album/love-me-again/1440813192?i=1440813380" + presence.detailsUrl = "https://music.apple.com/us/album/love-me-again/1440813192?i=1440813380" presence.state = "John Newman" - presence.state_url = "https://music.apple.com/us/artist/john-newman/649230577" + presence.stateUrl = "https://music.apple.com/us/artist/john-newman/649230577" // Show song title instead of "Music." - presence.status_display_type = .details + presence.statusDisplayType = .details // Assign image properties. presence.assets.largeImage = "big_sur_logo"