π€Basic Bot
Here are the basics to get your bot up and running.

import Discord
let bot = Bot(token: "<your token>", intents: Intents.default)
bot.run()Responding to a message

Slash Commands


Last updated
Here are the basics to get your bot up and running.

import Discord
let bot = Bot(token: "<your token>", intents: Intents.default)
bot.run()


Last updated
import Discord
let bot = Bot(token: "<your token>", intents: Intents.default)
class MyListener : EventListener {
override func onMessageCreate(message: Message) async {
// Don't respond to our own message
guard !message.author.isBot else {
return
}
if message.content == "hi swifty" {
try! await message.channel.send("Hello!")
}
}
}
try! bot.addListeners(MyListener(name: "example"))
bot.run()import Discord
let bot = Bot(token: "<your token>", intents: Intents.default)
bot.addSlashCommand(
name: "example",
description: "Example command",
guildId: 123456789012345678,
onInteraction: { interaction in
try! await interaction.respondWithMessage("This is an example")
}
)
try! await bot.syncApplicationCommands() // Only needs to be done once
bot.run()