diff --git a/Sources/zundamon/Wolfram.swift b/Sources/zundamon/Wolfram.swift index 5d78fbe..5b8fa6f 100644 --- a/Sources/zundamon/Wolfram.swift +++ b/Sources/zundamon/Wolfram.swift @@ -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,