Skip to main content

CmdrReplyUtils

Progress replies for commands that yield.

Cmdr prints nothing between dispatching a command and its body returning, so a command that spends seconds in a datastore retry ladder is indistinguishable from one that has hung. These replies fill that gap without adding a line to a command that finishes promptly.

local config = CmdrReplyUtils.createConfig()

return CmdrReplyUtils.replyWhenSlow(config, context, self:_promiseWork(userId), `{userId}: still working...`)
	:Then(function(line) ... end)

Types

CmdrReplyConfig

interface CmdrReplyConfig {
slowReplySecondsnumber--

How long work is given to finish before the executor is told it is still running

progressColorColor3--

Color of the progress reply

}

Functions

createConfig

CmdrReplyUtils.createConfig(
configtable?--

Optional table with overrides

) → CmdrReplyConfig

Creates a new reply config.

The default threshold is long enough that a command which completes promptly stays silent, and the default color is muted so progress chatter does not compete with the results printed after it.

isCmdrReplyConfig

CmdrReplyUtils.isCmdrReplyConfig(configany) → boolean

Returns whether an object is a reply config.

replyWhenSlow

CmdrReplyUtils.replyWhenSlow(
configCmdrReplyConfig,
contextCommandContext,
promisePromise<T...>,
textstring
) → Promise<T...>--

the promise that was passed in

Replies text to the executor if promise is still running slowReplySeconds from now, and says nothing at all if it settles first.

Returns the promise it was given, so it drops into an existing chain.

Show raw api
{
    "functions": [
        {
            "name": "createConfig",
            "desc": "Creates a new reply config.\n\nThe default threshold is long enough that a command which completes promptly stays silent, and\nthe default color is muted so progress chatter does not compete with the results printed after\nit.",
            "params": [
                {
                    "name": "config",
                    "desc": "Optional table with overrides",
                    "lua_type": "table?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "CmdrReplyConfig"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 52,
                "path": "src/cmdrservice/src/Shared/CmdrReplyUtils.lua"
            }
        },
        {
            "name": "isCmdrReplyConfig",
            "desc": "Returns whether an object is a reply config.",
            "params": [
                {
                    "name": "config",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 67,
                "path": "src/cmdrservice/src/Shared/CmdrReplyUtils.lua"
            }
        },
        {
            "name": "replyWhenSlow",
            "desc": "Replies `text` to the executor if `promise` is still running `slowReplySeconds` from now, and\nsays nothing at all if it settles first.\n\nReturns the promise it was given, so it drops into an existing chain.",
            "params": [
                {
                    "name": "config",
                    "desc": "",
                    "lua_type": "CmdrReplyConfig"
                },
                {
                    "name": "context",
                    "desc": "",
                    "lua_type": "CommandContext"
                },
                {
                    "name": "promise",
                    "desc": "",
                    "lua_type": "Promise<T...>"
                },
                {
                    "name": "text",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "the promise that was passed in",
                    "lua_type": "Promise<T...>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 85,
                "path": "src/cmdrservice/src/Shared/CmdrReplyUtils.lua"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "CmdrReplyConfig",
            "desc": "",
            "fields": [
                {
                    "name": "slowReplySeconds",
                    "lua_type": "number",
                    "desc": "How long work is given to finish before the executor is told it is still running"
                },
                {
                    "name": "progressColor",
                    "lua_type": "Color3",
                    "desc": "Color of the progress reply"
                }
            ],
            "source": {
                "line": 32,
                "path": "src/cmdrservice/src/Shared/CmdrReplyUtils.lua"
            }
        }
    ],
    "name": "CmdrReplyUtils",
    "desc": "Progress replies for commands that yield.\n\nCmdr prints nothing between dispatching a command and its body returning, so a command that\nspends seconds in a datastore retry ladder is indistinguishable from one that has hung. These\nreplies fill that gap without adding a line to a command that finishes promptly.\n\n```lua\nlocal config = CmdrReplyUtils.createConfig()\n\nreturn CmdrReplyUtils.replyWhenSlow(config, context, self:_promiseWork(userId), `{userId}: still working...`)\n\t:Then(function(line) ... end)\n```",
    "source": {
        "line": 18,
        "path": "src/cmdrservice/src/Shared/CmdrReplyUtils.lua"
    }
}