import { Effect } from "effect"
import type { Client } from "@neontechspace/fluxerly/effect"

export function askPreferredName(client: Client, channelId: string, userId: string) {
    return Effect.scoped(
        Effect.gen(function* () {
            const collector = yield* client.messages.collect(channelId, {
                filter: message => message.author.id === userId && !message.author.isBot,
                maxMessages: 1,
                timeoutMs: 30_000,
            })
            yield* client.messages.send(channelId, "What name should the bot use?")
            const result = yield* collector.result()
            return result.messages[0]?.content
        }),
    )
}
