fix: typing indicator lasting longer than 10s
This commit is contained in:
@@ -48,7 +48,12 @@ struct Wolfram {
|
||||
client: DiscordClient,
|
||||
ctx: MessageCreate
|
||||
) async throws {
|
||||
try await client.triggerTypingIndicator(channelId: ctx.channel_id)
|
||||
let typingIndicatorTask = Task {
|
||||
while !Task.isCancelled {
|
||||
try await client.triggerTypingIndicator(channelId: ctx.channel_id)
|
||||
try await Task.sleep(for: .seconds(8))
|
||||
}
|
||||
}
|
||||
|
||||
let question = String(args.joined(separator: " "))
|
||||
|
||||
@@ -59,6 +64,7 @@ struct Wolfram {
|
||||
if let img = img {
|
||||
attachments.append(.init(image: .init(url: img.absoluteString)))
|
||||
}
|
||||
typingIndicatorTask.cancel()
|
||||
|
||||
try await client.createMessage(channelId: ctx.channel_id, payload: .init(
|
||||
content: answer,
|
||||
|
||||
Reference in New Issue
Block a user