use multiple threads to respond to messages
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user