Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Sources/SwordRPC/Types/Enums.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 <name>"
case name = 0
/// "Playing <state>"
case state = 1
/// "Playing <details>"
case details = 2
}
18 changes: 18 additions & 0 deletions Sources/SwordRPC/Types/RichPresence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}
}
Expand Down
13 changes: 9 additions & 4 deletions Tests/SwordRPCTests/SwordRPCTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down