Swiftpack.co - SketchMaster2001/Swiftcord as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by SketchMaster2001.
SketchMaster2001/Swiftcord 0.9.3
Swift wrapper for Discord's API. Maintained fork of Azoy's Sword.
⭐️ 18
🕓 1 week ago
.package(url: "https://github.com/SketchMaster2001/Swiftcord.git", from: "0.9.3")

Swift Version Tag

Swiftcord - A Discord Library for Swift


  1. macOS, Linux, iOS, watchOS, tvOS (no voice for iOS, watchOS, or tvOS)
  2. At least Swift 5.3

Adding Sword

Swift Package Manager

In order to add Sword as a dependency, you must first create a Swift executable in a designated folder, like so swift package init --type executable. Then in the newly created Package.swift, open it and add Sword as a dependency

// swift-tools-version: 5.3

import PackageDescription

let package = Package(
    name: "yourswiftexecutablehere",
    dependencies: [
        .package(url: "https://github.com/SketchMaster2001/Swiftcord", .branch("master"))
    targets: [
        name: "yourswiftexecutablehere",
        dependencies: ["Swiftcord"]

After that, open Sources/main.swift and remove everything and replace it with the example below.

import Swiftcord

let bot = Swiftcord(token: "Your bot token here")

// Set activity if wanted
let activity = Activities(name: "with Swiftcord!", type: .playing)
bot.editStatus(status: .online, activity: activity)

// Set intents which are required
bot.setIntents(intents: .guildMessages)

bot.on(.messageCreate) { data in
  let msg = data as! Message

  if msg.content == "!ping" {
    msg.reply(with: "Pong!")


For more examples, look in the examples folder or in the Wiki.

Running the bot (SPM)

First make sure you are in the directory with the Package.swift file. To build the executable, run swift build. To build the executable and run it immediately, run swift run

Running the bot in Xcode (SPM)

To run the bot in Xcode, all you need to do is open the directory the Package.swift file is located in Xcode. Click the play button at the top left corner and it will run!

Then click the play button!


Documentation - Created using Apple docc and converted to HTML with docc2html

Swiftcord Discord server


Stars: 18
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

1 week ago

Swiftcord Release v0.9.3

This release fixes issues that may occur with the web socket connection.

Big thanks to @BennyDeBock and @0xTim!

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics