import assert from "node:assert/strict"
import { test } from "node:test"
import { createTestBot } from "@neontechspace/fluxerly/testing"

test("a command that throws is reported", async () => {
    await using bot = createTestBot({
        commands: {
            prefix: "!",
            commands: {
                broken: {
                    execute: () => {
                        throw new Error("Not implemented yet")
                    },
                },
            },
        },
    })
    await bot.ready()
    bot.emit("MESSAGE_CREATE", bot.fixtures.message({ content: "!broken" }))

    await bot.idle()
    assert.deepEqual(
        bot.failures().map((record) => record.code),
        ["commands.failed"],
    )
})
