const raw_text = "https://git.ragestudio.net/srgooglo/monstercanker/raw/branch/main/main.txt"

function randomSelect(array) {
    return array[Math.floor(Math.random() * array.length)]
}

module.exports = async ({ random } = {}) => {
    const response = await fetch(raw_text)

    let phrases = await response.text()

    phrases = phrases.split("\n")

    if (random) {
        if (typeof random === "number") {
            const randomSelections = []

            for await (const _ of Array(random)) {
                randomSelections.push(randomSelect(phrases))
            }

            phrases = randomSelections
        } else {
            phrases = randomSelect(phrases)
        }
    }

    return phrases
}