Running your bot
Instructions are available per platform.
With Xcode (recommended)
Ensure the scheme is set to your bot, and press the run button. It will build for debugging unless you change the scheme settings.
With a terminal
Open a terminal, cd
to your bot project directory,
and paste the following command.
Open a terminal, cd
to your bot project directory,
and paste the following command.
If you have no other choice, you can run your bot on an iDevice. It’s not recommended, but it’s possible. DDBKit does not regularly test on iDevices, so you may run into issues. If you do, please report them in a GitHub issue.
DiscordBotShell
You will need to migrate your codebase to work on iOS, and make a new project forked from the template shell app. You can find the shell app at DiscordBotShell.
Begin by navigating to the repository, then click on Use this template
.
Give your repository a name, and clone it to your local machine.
Your project structure should look like this:
- DiscordBotShell.xcodeproj
DirectoryDiscordBotShell
DirectoryShell
- …
DirectoryBot
- BotMain.swift
- DiscordBotShell.entitlements
- Info.plist
DirectoryDiscordBotShellTests
- DiscordBotShellTests.swift
Next, copy your bot code from your Sources
folder to the Bot
folder.
You can remove
BotMain.swift
if your bot’s entrypoint is in a different file.
Go to your bot’s entrypoint struct, remove the @main
attribute. DiscordBotShell will handle the entrypoint.
Rename the struct to MyDiscordBot
, since that’s what the shell app is looking for at launch.
Finally, build and run your bot on your iDevice.
Installing Swift
Open your preferred package manager, and install Swift. You should know how to do this if you’re jailbroken.
Running your bot
Open a terminal, cd
to your bot project directory, clone if necessary, and then run as you would on other platforms.
Deployment
Binary (for macOS)
We recommend this if you’re hosting on a macOS server, and your bot relies on macOS frameworks.
Begin by building your bot for release with the following command:
The final binary will be located in a folder in the .build/
folder.
The destination folder will be named after your host architecture.
You can then copy the binary and required resources to your server, and run it with any required arguments or environment variables.
To ensure the bot launches on boot, you can use a launchd plist. You can find more information on launchd plists at Apple’s developer documentation.
Docker (recommended)
We recommend this if you’re hosting on a Linux server, or if you’re hosting on a macOS server but don’t deal with macOS frameworks.
First, make sure you have docker
and docker-compose
installed.
You can install them using your distro’s package manager, or by
using the official Docker installation script, located
here.
Start by making a Dockerfile
in your bot project directory.
It might look something like this:
This example Dockerfile
builds your bot using a full swift image, and runs it on a smaller, more optimized image.
You can then run the newly-created docker image with docker run
, however it is highly recommended to use docker-compose.
A minimal docker-compose.yml
may look like this:
Start the docker image by running docker compose up -d
in the same directory as the compose file.
If you need to specify environment variables or other options, you can find a more in-depth example here.
Special
If you’re hosting on an iDevice, you can use the same instructions as running on an iDevice. There is no better way to deploy on an iDevice, as it’s not recommended. You can be assured that it’s at least safe and sandboxed unless you used the jailbroken method. But it’s not recommended for production use anyways. Maybe just useful for flexing on your friends idk.