use multiple threads to respond to messages

This commit is contained in:
2026-03-25 17:44:34 -04:00
parent a1ed1564b9
commit 32c9f0fd6c
2 changed files with 21 additions and 11 deletions
+14 -6
View File
@@ -23,13 +23,21 @@ struct Zundamon {
try await bot.connect()
for await event in await bot.events {
switch event {
case .messageCreate(let event):
try await MessageHandler(ctx: event, client: bot.client).handle()
default:
continue
await withThrowingTaskGroup(of: Void.self) { group in
for i in 0...5 {
group.addTask {
for await event in await bot.events {
print(i)
switch event {
case .messageCreate(let event):
try await MessageHandler(ctx: event, client: bot.client).handle()
default:
continue
}
}
}
}
}
print("bottom of main")
}