Wanna talk about Swiftcord/Discord or just hang around? Join us in Discord!
A beautiful and blazingly fast native macOS Discord client, built in SwiftUI.
Give Swiftcord a try! Nightly builds (recommended) are built from every commit on main
, while releases are more stable but updated less frequently.
The missing Swift Discord library. Build elegant Discord bots with a simple resultBuilder-powered slash command builder.
Here's all you need to build a bot with DiscordKit (it's that simple):
import DiscordKitBot
let bot = Client(intents: .unprivileged)
// Guild to register commands in. If the COMMAND_GUILD_ID environment variable is set, commands are scoped
// to that server and update instantly, useful for debugging. Otherwise, they are registered globally.
let commandGuildID = ProcessInfo.processInfo.environment["COMMAND_GUILD_ID"]
bot.ready.listen {
print("Logged in as \(bot.user!.username)#\(bot.user!.discriminator)!")
try? await bot.registerApplicationCommands(guild: commandGuildID) {
NewAppCommand("ping", description: "Ping me!") { interaction in
try? await interaction.reply("Pong!")
}
}
}
bot.login() // Reads the bot token from the DISCORD_TOKEN environment variable and logs in with the token
// Run the main RunLoop to prevent the program from exiting
RunLoop.main.run()