feat: sending messages works
This commit is contained in:
@@ -4,7 +4,7 @@ import SwiftDotenv
|
||||
|
||||
@main
|
||||
struct Zundamon {
|
||||
//nonisolated(unsafe) static private(set) var ownID: UserSnowflake? = nil
|
||||
nonisolated(unsafe) static private(set) var ownID: String? = nil
|
||||
|
||||
static func main() async throws {
|
||||
if case .failure = Result(catching: { try Dotenv.configure() }) {
|
||||
@@ -16,9 +16,10 @@ struct Zundamon {
|
||||
guard !token.isEmpty else { fatalError("Err: Empty DISCORD_TOKEN. Exiting...") }
|
||||
|
||||
let intents: Intents = [.guilds, .guildMessages, .messageContent, .guildMembers, .directMessages]
|
||||
print(intents)
|
||||
|
||||
let bot = try await DiscordKit.Bot(token: token, intents: intents)
|
||||
ownID = try await bot.client.getOwnUser().id
|
||||
guard ownID != nil else { fatalError("Failed to get own User ID") }
|
||||
|
||||
// let bot = await BotGatewayManager(token: token, intents: [.guildMessages, .messageContent])
|
||||
|
||||
@@ -30,6 +31,12 @@ struct Zundamon {
|
||||
taskGroup.addTask {
|
||||
for await event in await bot.events {
|
||||
dump(event)
|
||||
switch event.d {
|
||||
case .messageCreate(let event):
|
||||
try await MessageHandler(ctx: event, client: bot.client).handle()
|
||||
default:
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user