function Promise.retryWithDelay(S,Q,X,...)assert(isCallable(S),"\080\097\114\097\109\101\116\101\114 \035\049 \116\111 \080\114\111\109\105\115\101\046\114\101\116\114\121 \109\117\115\116 \098\101 \097 \102\117\110\099\116\105\111\110")assert(type(Q)=="\110\117\109\098\101\114","\080\097\114\097\109\101\116\101\114 \035\050 \040\116\105\109\101\115\041 \116\111 \080\114\111\109\105\115\101\046\114\101\116\114\121 \109\117\115\116 \098\101 \097 \110\117\109\098\101\114")assert(type(X)=="\110\117\109\098\101\114","\080\097\114\097\109\101\116\101\114 \035\051 \040\115\101\099\111\110\100\115\041 \116\111 \080\114\111\109\105\115\101\046\114\101\116\114\121 \109\117\115\116 \098\101 \097 \110\117\109\098\101\114")local y,V={...},select("\035",...)return(Promise.resolve(S(...))):catch(function(...)if Q>0 then(Promise.delay(X)):await()return Promise.retryWithDelay(S,Q-1,X,unpack(y,1,V))else return Promise.reject(...)end end)end
--[=[
	Repeatedly calls a Promise-returning function up to `times` number of times, waiting `seconds` seconds between each
	retry, until the returned Promise resolves.

	If the amount of retries is exceeded, the function will return the latest rejected Promise.

	@since v3.2.0
	@param callback (...: P) -> Promise<T>
	@param times number
	@param seconds number
	@param ...? P
	@return Promise<T>
]=]
function Promise.retryWithDelay(callback, times, seconds, ...)
	assert(isCallable(callback), "Parameter #1 to Promise.retry must be a function")
	assert(type(times) == "number", "Parameter #2 (times) to Promise.retry must be a number")
	assert(type(seconds) == "number", "Parameter #3 (seconds) to Promise.retry must be a number")

	local args, length = { ... }, select("#", ...)

	return Promise.resolve(callback(...)):catch(function(...)
		if times > 0 then
			Promise.delay(seconds):await()

			return Promise.retryWithDelay(callback, times - 1, seconds, unpack(args, 1, length))
		else
			return Promise.reject(...)
		end
	end)
end
