-
Notifications
You must be signed in to change notification settings - Fork 32
[SwordRPC] Discord not detected #1
Description
Hey there!
I recently started using SwordRPC for a project but keep getting the following error:
[SwordRPC] Error creating URL scheme: -54 [SwordRPC] Discord not detected error: Optional({ NSAppleScriptErrorBriefMessage = "A unknown token can\U2019t go here."; NSAppleScriptErrorMessage = "A unknown token can\U2019t go here."; NSAppleScriptErrorNumber = "-2740"; NSAppleScriptErrorRange = "NSRange: {0, 1}"; })
This is my ViewController.swift:
`
//
// ViewController.swift
// iTunes4Discord
//
// Created by Conor on 06/07/2018.
// Copyright © 2018 Conor Byrne. All rights reserved.
//
import Cocoa
import SwordRPC
class ViewController: NSViewController {
override func viewDidLoad() {
super.viewDidLoad()
let rpc = SwordRPC(appId: "464708073248915457")
rpc.onConnect { rpc in
var presence = RichPresence()
presence.details = "null"
presence.state = "In a Group"
presence.timestamps.start = Date()
presence.timestamps.end = Date() + 600 // 600s = 10m
presence.assets.largeImage = "itunes"
presence.assets.largeText = "iTunes v12.7.5.9"
presence.assets.smallImage = ""
presence.assets.smallText = ""
presence.party.max = 5
presence.party.size = 3
presence.party.id = "partyId"
presence.secrets.match = "matchSecret"
presence.secrets.join = "joinSecret"
rpc.setPresence(presence)
}
rpc.onDisconnect { rpc, code, msg in
print("It appears we have disconnected from Discord")
}
rpc.onError { rpc, code, msg in
print("It appears we have discovered an error!")
}
rpc.onJoinGame { rpc, secret in
print("We have found us a join game secret!")
}
rpc.onSpectateGame { rpc, secret in
print("Our user wants to spectate!")
}
rpc.onJoinRequest { rpc, request, secret in
print("Some user wants to play with us!")
rpc.reply(to: request, with: .no)
}
rpc.connect()
/*
let myAppleScript = "..."
var error: NSDictionary?
if let scriptObject = NSAppleScript(source: myAppleScript) {
if let output: NSAppleEventDescriptor = scriptObject.executeAndReturnError(
&error) {
print(output.stringValue)
} else if (error != nil) {
print("error: \(error)")
}
}
*/
}
override var representedObject: Any? {
didSet {
// Update the view, if already loaded.
}
}
}
extension ViewController: SwordRPCDelegate {
func swordRPCDidConnect(
_ rpc: SwordRPC
) {}
func swordRPCDidDisconnect(
_ rpc: SwordRPC,
code: Int?,
message msg: String?
) {}
func swordRPCDidReceiveError(
_ rpc: SwordRPC,
code: Int,
message msg: String
) {}
func swordRPCDidJoinGame(
_ rpc: SwordRPC,
secret: String
) {}
func swordRPCDidSpectateGame(
_ rpc: SwordRPC,
secret: String
) {}
func swordRPCDidReceiveJoinRequest(
_ rpc: SwordRPC,
request: JoinRequest,
secret: String
) {}
}
`
Running on macOS 10.13 with Xcode 9.4.1, also tried on Xcode 10 beta 3