fix: typing indicator lasting longer than 10s

This commit is contained in:
Andrew Glaze
2026-03-20 22:37:55 -04:00
parent 85c699412f
commit bc72fc9781

View File

@@ -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,