Creating a bot using a SPM project (Recommended)

Don't have a project to use DiscordKit with? These instructions are for you!

Prerequisites

macOS
  • Latest version of Xcode (14.3 as of writing)

Linux
  • The latest Swift toolchain (5.8 as of writing)

  • A code editor of your choosing

    • We strongly recommend using VSCode with the "Swift" Extension by "Swift Server Work Group" if you're starting out with swift, although it's not required.

Creating a Swift CLI package

  1. Open a terminal window, then create a new directory for your project to live in, and then change directory into it:

mkdir MyWonderfulBot
cd MyWonderfulBot
  1. Create a new swift package with the following command (Don't forget the --type=executable otherwise you won't be able to run your bot)

swift package init --type=executable

And that's it! If you're using Xcode, open the Package.swift file so that Xcode knows to load the package. If you're using a different editor, such as VSCode, open the entire folder.

Last updated