/SwiftcordIPC

A lightweight and *working* Swift library for communicating with Discord via IPC

Primary LanguageSwiftMIT LicenseMIT

SwiftcordIPC

A light-weight and easy to use Discord IPC library backed by swift-nio

Swift Version License

Swiftcord IPC is an easy to use Discord IPC library. Many other RPC / IPC libraries for Discord in Swift either don't work, or are very buggy. SwiftcordIPC is designed to be reliable and up-to-date.

Note: At the moment, we have not found a way to use SwiftcordIPC inside the App Sandbox, however I am actively working on a solution for this.

Installation

Add this project to your Package.swift

import PackageDescription

let package = Package(
    dependencies: [
        .Package(url: "https://github.com/cbyrneee/SwiftcordIPC.git", from: "1.0.0")
    ]
)

Usage example

import SwiftcordIPC

let ipc = SwiftcordIPC(id: "937029972139327558")
ipc.onReady = { data in
    print("Ready! User: \(data.user.username)#\(data.user.discriminator)")
    
    ipc.setPresence { data in
        data.details = "hello"
        data.state = "world"
        data.assets = assets(largeImage: "hello", largeImageText: "world")
        data.buttons = [
            button(label: "click me!", url: "https://cbyrne.dev")
        ]
    }
}

// An error will be thrown here if connection has failed, e.g. ConnectionError.noIpcFile
try ipc.connectAndBlock()

Meta

Conor Byrne – @cbyrnedevhello@cbyrne.dev

Distributed under the MIT license. See LICENSE for more information.