HTTP 400 when attempting permanent ban through OpenCloud API?

Hello!

I recently decided to develop a Discord bot to help me moderate my game without having to go to the Roblox website. One of the things I made was a ban command, which uses OpenCloud API to ban a user from my game.

This works perfectly fine… except when I try to permanently ban the user. At that point, it gives me HTTP 400 (bad request). By the way, I am using the -1 ban value.

Code in Roblox for context

How the code would be in Roblox:

Players:BanAsync({ --obviously in a pcall
    UserIds = {--[[userIds]]),
    Duration = -1,
    ApplyToUniverse = true,
    ExcludeAltAccounts = false,
    PrivateReason = "some private reason",
    DisplayReason = "some display reason"
})

My current code in JavaScript:

//this has been shortened, some variables should be self explanatory. If not, please ask.
//get timestamp
function getTimestamp() {
    const date = new Date();
    return date.toISOString();
};

//ban command
commands["ban"] = async function(parameters, channel) { //channel is the Discord channel
    const banBody = JSON.stringify({
        gameJoinRestriction: {
            active: true,
            startTime: getTimestamp(),
            duration: String(length) + "s",
            privateReason: "Ban request from Discord bot. Reason: " + reason,
            displayReason: reason,
            excludeAltAccounts: false,
            inherited: true
        }
    });

    //get the final URL
    const url = endpoints.ban + String(userId);
    
    //send the request
    const response = await fetch(url, {
        method: "PATCH",
        headers: {
            "Content-Type": "application/json",
            "x-api-key": apiKey
        },
        body: banBody
    });

    //if it failed
    if (!response.ok) {
        channel.send("Failed to ban user. Please try again. Error code: " + String(response.status));
    } else { //if it succeeded
        channel.send("Successfully banned user.");
    };
};

If I input a time length, like 5 minutes, in seconds, so 300, it works fine. But, if I put in -1, it returns HTTP 400.

So… I guess I’m asking if anyone knows how to make it permanent? Can it be made permanent?

You can try making the seconds a huge number like math.huge

Still returns HTTP 400. math.huge also doesn’t work with Players:BanAsync() in Luau, neither Infinity in JavaScript, so I wonder why -1 doesn’t work in JavaScript also…