@sapphire/ratelimits 2.4.4 → 2.4.5-next.8eefb1e.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +213 -0
- package/dist/index.global.js +789 -6
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +63 -58
- package/LICENSE.md +0 -24
package/dist/index.global.js
CHANGED
|
@@ -68,14 +68,505 @@ var SapphireRatelimits = (() => {
|
|
|
68
68
|
return this;
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
|
+
__name(RateLimit, "RateLimit");
|
|
71
72
|
|
|
72
|
-
// ../
|
|
73
|
+
// ../utilities/dist/index.mjs
|
|
73
74
|
var __defProp2 = Object.defineProperty;
|
|
74
|
-
var
|
|
75
|
+
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
|
|
76
|
+
function arrayStrictEquals(arr1, arr2) {
|
|
77
|
+
if (arr1 === arr2)
|
|
78
|
+
return true;
|
|
79
|
+
if (arr1.length !== arr2.length)
|
|
80
|
+
return false;
|
|
81
|
+
for (let i = 0; i < arr1.length; i++) {
|
|
82
|
+
if (arr1[i] !== arr2[i] || typeof arr1[i] !== typeof arr2[i])
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
__name(arrayStrictEquals, "arrayStrictEquals");
|
|
88
|
+
__name2(arrayStrictEquals, "arrayStrictEquals");
|
|
89
|
+
function cast(value) {
|
|
90
|
+
return value;
|
|
91
|
+
}
|
|
92
|
+
__name(cast, "cast");
|
|
93
|
+
__name2(cast, "cast");
|
|
94
|
+
function chunk(array, chunkSize) {
|
|
95
|
+
if (!Array.isArray(array))
|
|
96
|
+
throw new TypeError("entries must be an array.");
|
|
97
|
+
if (!Number.isInteger(chunkSize))
|
|
98
|
+
throw new TypeError("chunkSize must be an integer.");
|
|
99
|
+
if (chunkSize < 1)
|
|
100
|
+
throw new RangeError("chunkSize must be 1 or greater.");
|
|
101
|
+
const clone = array.slice();
|
|
102
|
+
const chunks = [];
|
|
103
|
+
while (clone.length)
|
|
104
|
+
chunks.push(clone.splice(0, chunkSize));
|
|
105
|
+
return chunks;
|
|
106
|
+
}
|
|
107
|
+
__name(chunk, "chunk");
|
|
108
|
+
__name2(chunk, "chunk");
|
|
109
|
+
function classExtends(value, base) {
|
|
110
|
+
let ctor = value;
|
|
111
|
+
while (ctor !== null) {
|
|
112
|
+
if (ctor === base)
|
|
113
|
+
return true;
|
|
114
|
+
ctor = Object.getPrototypeOf(ctor);
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
__name(classExtends, "classExtends");
|
|
119
|
+
__name2(classExtends, "classExtends");
|
|
120
|
+
var zws = String.fromCharCode(8203);
|
|
121
|
+
function codeBlock(language, expression) {
|
|
122
|
+
if (typeof expression === "string") {
|
|
123
|
+
if (expression.length === 0)
|
|
124
|
+
return `\`\`\`${zws}\`\`\``;
|
|
125
|
+
return `\`\`\`${language}
|
|
126
|
+
${expression.replace(/```/, `\`${zws}\`\``).replace(/`$/g, `\`${zws}`)}\`\`\``;
|
|
127
|
+
}
|
|
128
|
+
return `\`\`\`${language}
|
|
129
|
+
${expression || zws}\`\`\``;
|
|
130
|
+
}
|
|
131
|
+
__name(codeBlock, "codeBlock");
|
|
132
|
+
__name2(codeBlock, "codeBlock");
|
|
133
|
+
function splitText(str, length, char = " ") {
|
|
134
|
+
const x = str.substring(0, length).lastIndexOf(char);
|
|
135
|
+
const pos = x === -1 ? length : x;
|
|
136
|
+
return str.substring(0, pos);
|
|
137
|
+
}
|
|
138
|
+
__name(splitText, "splitText");
|
|
139
|
+
__name2(splitText, "splitText");
|
|
140
|
+
function cutText(str, length) {
|
|
141
|
+
if (str.length < length)
|
|
142
|
+
return str;
|
|
143
|
+
const cut = splitText(str, length - 3);
|
|
144
|
+
if (cut.length < length - 3)
|
|
145
|
+
return `${cut}...`;
|
|
146
|
+
return `${cut.slice(0, length - 3)}...`;
|
|
147
|
+
}
|
|
148
|
+
__name(cutText, "cutText");
|
|
149
|
+
__name2(cutText, "cutText");
|
|
150
|
+
function debounce(func, options = {}) {
|
|
151
|
+
var _a;
|
|
152
|
+
let lastArgs;
|
|
153
|
+
let result;
|
|
154
|
+
let timerId;
|
|
155
|
+
let lastCallTime;
|
|
156
|
+
let lastInvokeTime = 0;
|
|
157
|
+
const wait = (_a = options.wait) != null ? _a : 0;
|
|
158
|
+
const maxWait = typeof options.maxWait === "number" ? Math.max(options.maxWait, wait) : null;
|
|
159
|
+
function invokeFunc(time) {
|
|
160
|
+
const args = lastArgs;
|
|
161
|
+
lastArgs = void 0;
|
|
162
|
+
lastInvokeTime = time;
|
|
163
|
+
result = func(...args);
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
__name(invokeFunc, "invokeFunc");
|
|
167
|
+
__name2(invokeFunc, "invokeFunc");
|
|
168
|
+
function leadingEdge(time) {
|
|
169
|
+
lastInvokeTime = time;
|
|
170
|
+
timerId = setTimeout(timerExpired, wait);
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
173
|
+
__name(leadingEdge, "leadingEdge");
|
|
174
|
+
__name2(leadingEdge, "leadingEdge");
|
|
175
|
+
function remainingWait(time) {
|
|
176
|
+
const timeSinceLastCall = time - lastCallTime;
|
|
177
|
+
const timeSinceLastInvoke = time - lastInvokeTime;
|
|
178
|
+
const result2 = wait - timeSinceLastCall;
|
|
179
|
+
return maxWait === null ? result2 : Math.min(result2, maxWait - timeSinceLastInvoke);
|
|
180
|
+
}
|
|
181
|
+
__name(remainingWait, "remainingWait");
|
|
182
|
+
__name2(remainingWait, "remainingWait");
|
|
183
|
+
function shouldInvoke(time) {
|
|
184
|
+
const timeSinceLastCall = time - lastCallTime;
|
|
185
|
+
const timeSinceLastInvoke = time - lastInvokeTime;
|
|
186
|
+
return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxWait !== null && timeSinceLastInvoke >= maxWait;
|
|
187
|
+
}
|
|
188
|
+
__name(shouldInvoke, "shouldInvoke");
|
|
189
|
+
__name2(shouldInvoke, "shouldInvoke");
|
|
190
|
+
function timerExpired() {
|
|
191
|
+
const time = Date.now();
|
|
192
|
+
if (shouldInvoke(time)) {
|
|
193
|
+
trailingEdge(time);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
197
|
+
}
|
|
198
|
+
__name(timerExpired, "timerExpired");
|
|
199
|
+
__name2(timerExpired, "timerExpired");
|
|
200
|
+
function trailingEdge(time) {
|
|
201
|
+
timerId = void 0;
|
|
202
|
+
return invokeFunc(time);
|
|
203
|
+
}
|
|
204
|
+
__name(trailingEdge, "trailingEdge");
|
|
205
|
+
__name2(trailingEdge, "trailingEdge");
|
|
206
|
+
function cancel() {
|
|
207
|
+
if (timerId !== void 0) {
|
|
208
|
+
clearTimeout(timerId);
|
|
209
|
+
}
|
|
210
|
+
lastInvokeTime = 0;
|
|
211
|
+
lastArgs = void 0;
|
|
212
|
+
lastCallTime = void 0;
|
|
213
|
+
timerId = void 0;
|
|
214
|
+
}
|
|
215
|
+
__name(cancel, "cancel");
|
|
216
|
+
__name2(cancel, "cancel");
|
|
217
|
+
function flush() {
|
|
218
|
+
return timerId === void 0 ? result : trailingEdge(Date.now());
|
|
219
|
+
}
|
|
220
|
+
__name(flush, "flush");
|
|
221
|
+
__name2(flush, "flush");
|
|
222
|
+
function debounced(...args) {
|
|
223
|
+
const time = Date.now();
|
|
224
|
+
const isInvoking = shouldInvoke(time);
|
|
225
|
+
lastArgs = args;
|
|
226
|
+
lastCallTime = time;
|
|
227
|
+
if (isInvoking) {
|
|
228
|
+
if (timerId === void 0) {
|
|
229
|
+
return leadingEdge(lastCallTime);
|
|
230
|
+
}
|
|
231
|
+
if (maxWait !== null) {
|
|
232
|
+
timerId = setTimeout(timerExpired, wait);
|
|
233
|
+
return invokeFunc(lastCallTime);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (timerId === void 0) {
|
|
237
|
+
timerId = setTimeout(timerExpired, wait);
|
|
238
|
+
}
|
|
239
|
+
return result;
|
|
240
|
+
}
|
|
241
|
+
__name(debounced, "debounced");
|
|
242
|
+
__name2(debounced, "debounced");
|
|
243
|
+
debounced.cancel = cancel;
|
|
244
|
+
debounced.flush = flush;
|
|
245
|
+
return debounced;
|
|
246
|
+
}
|
|
247
|
+
__name(debounce, "debounce");
|
|
248
|
+
__name2(debounce, "debounce");
|
|
249
|
+
var primitiveTypes = ["string", "bigint", "number", "boolean"];
|
|
250
|
+
function isPrimitive(input) {
|
|
251
|
+
return primitiveTypes.includes(typeof input);
|
|
252
|
+
}
|
|
253
|
+
__name(isPrimitive, "isPrimitive");
|
|
254
|
+
__name2(isPrimitive, "isPrimitive");
|
|
255
|
+
function deepClone(source) {
|
|
256
|
+
if (source === null || isPrimitive(source)) {
|
|
257
|
+
return source;
|
|
258
|
+
}
|
|
259
|
+
if (source instanceof Date) {
|
|
260
|
+
const output = new source.constructor(source);
|
|
261
|
+
return output;
|
|
262
|
+
}
|
|
263
|
+
if (Array.isArray(source)) {
|
|
264
|
+
const output = new source.constructor(source.length);
|
|
265
|
+
for (let i = 0; i < source.length; i++) {
|
|
266
|
+
output[i] = deepClone(source[i]);
|
|
267
|
+
}
|
|
268
|
+
return output;
|
|
269
|
+
}
|
|
270
|
+
if (source instanceof Map) {
|
|
271
|
+
const output = new source.constructor();
|
|
272
|
+
for (const [key, value] of source.entries()) {
|
|
273
|
+
output.set(key, deepClone(value));
|
|
274
|
+
}
|
|
275
|
+
return output;
|
|
276
|
+
}
|
|
277
|
+
if (source instanceof Set) {
|
|
278
|
+
const output = new source.constructor();
|
|
279
|
+
for (const value of source.values()) {
|
|
280
|
+
output.add(deepClone(value));
|
|
281
|
+
}
|
|
282
|
+
return output;
|
|
283
|
+
}
|
|
284
|
+
if (typeof source === "object") {
|
|
285
|
+
const output = new source.constructor();
|
|
286
|
+
for (const [key, value] of Object.entries(source)) {
|
|
287
|
+
Object.defineProperty(output, key, {
|
|
288
|
+
configurable: true,
|
|
289
|
+
enumerable: true,
|
|
290
|
+
value: deepClone(value),
|
|
291
|
+
writable: true
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
return output;
|
|
295
|
+
}
|
|
296
|
+
return source;
|
|
297
|
+
}
|
|
298
|
+
__name(deepClone, "deepClone");
|
|
299
|
+
__name2(deepClone, "deepClone");
|
|
300
|
+
function isNullOrUndefined(value) {
|
|
301
|
+
return value === void 0 || value === null;
|
|
302
|
+
}
|
|
303
|
+
__name(isNullOrUndefined, "isNullOrUndefined");
|
|
304
|
+
__name2(isNullOrUndefined, "isNullOrUndefined");
|
|
305
|
+
function filterNullAndUndefined(value) {
|
|
306
|
+
return !isNullOrUndefined(value);
|
|
307
|
+
}
|
|
308
|
+
__name(filterNullAndUndefined, "filterNullAndUndefined");
|
|
309
|
+
__name2(filterNullAndUndefined, "filterNullAndUndefined");
|
|
310
|
+
function isNullOrUndefinedOrEmpty(value) {
|
|
311
|
+
return isNullOrUndefined(value) || value.length === 0;
|
|
312
|
+
}
|
|
313
|
+
__name(isNullOrUndefinedOrEmpty, "isNullOrUndefinedOrEmpty");
|
|
314
|
+
__name2(isNullOrUndefinedOrEmpty, "isNullOrUndefinedOrEmpty");
|
|
315
|
+
function filterNullAndUndefinedAndEmpty(value) {
|
|
316
|
+
return !isNullOrUndefinedOrEmpty(value);
|
|
317
|
+
}
|
|
318
|
+
__name(filterNullAndUndefinedAndEmpty, "filterNullAndUndefinedAndEmpty");
|
|
319
|
+
__name2(filterNullAndUndefinedAndEmpty, "filterNullAndUndefinedAndEmpty");
|
|
320
|
+
function isNullOrUndefinedOrZero(value) {
|
|
321
|
+
return value === 0 || isNullOrUndefined(value);
|
|
322
|
+
}
|
|
323
|
+
__name(isNullOrUndefinedOrZero, "isNullOrUndefinedOrZero");
|
|
324
|
+
__name2(isNullOrUndefinedOrZero, "isNullOrUndefinedOrZero");
|
|
325
|
+
function filterNullAndUndefinedAndZero(value) {
|
|
326
|
+
return !isNullOrUndefinedOrZero(value);
|
|
327
|
+
}
|
|
328
|
+
__name(filterNullAndUndefinedAndZero, "filterNullAndUndefinedAndZero");
|
|
329
|
+
__name2(filterNullAndUndefinedAndZero, "filterNullAndUndefinedAndZero");
|
|
330
|
+
function hasAtLeastOneKeyInMap(map, keys) {
|
|
331
|
+
return keys.some((key) => map.has(key));
|
|
332
|
+
}
|
|
333
|
+
__name(hasAtLeastOneKeyInMap, "hasAtLeastOneKeyInMap");
|
|
334
|
+
__name2(hasAtLeastOneKeyInMap, "hasAtLeastOneKeyInMap");
|
|
335
|
+
var zws2 = String.fromCharCode(8203);
|
|
336
|
+
function inlineCodeBlock(input) {
|
|
337
|
+
return `\`${input.replace(/ /g, "\xA0").replace(/`/g, `\`${zws2}`)}\``;
|
|
338
|
+
}
|
|
339
|
+
__name(inlineCodeBlock, "inlineCodeBlock");
|
|
340
|
+
__name2(inlineCodeBlock, "inlineCodeBlock");
|
|
341
|
+
function isClass(input) {
|
|
342
|
+
return typeof input === "function" && typeof input.prototype === "object";
|
|
343
|
+
}
|
|
344
|
+
__name(isClass, "isClass");
|
|
345
|
+
__name2(isClass, "isClass");
|
|
346
|
+
function isFunction(input) {
|
|
347
|
+
return typeof input === "function";
|
|
348
|
+
}
|
|
349
|
+
__name(isFunction, "isFunction");
|
|
350
|
+
__name2(isFunction, "isFunction");
|
|
351
|
+
function isNumber(input) {
|
|
352
|
+
return typeof input === "number" && !isNaN(input) && Number.isFinite(input);
|
|
353
|
+
}
|
|
354
|
+
__name(isNumber, "isNumber");
|
|
355
|
+
__name2(isNumber, "isNumber");
|
|
356
|
+
function isObject(input, constructorType) {
|
|
357
|
+
return typeof input === "object" && input ? input.constructor === (constructorType != null ? constructorType : Object) : false;
|
|
358
|
+
}
|
|
359
|
+
__name(isObject, "isObject");
|
|
360
|
+
__name2(isObject, "isObject");
|
|
361
|
+
function hasThen(input) {
|
|
362
|
+
return Reflect.has(input, "then") && isFunction(input.then);
|
|
363
|
+
}
|
|
364
|
+
__name(hasThen, "hasThen");
|
|
365
|
+
__name2(hasThen, "hasThen");
|
|
366
|
+
function hasCatch(input) {
|
|
367
|
+
return Reflect.has(input, "catch") && isFunction(input.catch);
|
|
368
|
+
}
|
|
369
|
+
__name(hasCatch, "hasCatch");
|
|
370
|
+
__name2(hasCatch, "hasCatch");
|
|
371
|
+
function isThenable(input) {
|
|
372
|
+
if (typeof input !== "object" || input === null)
|
|
373
|
+
return false;
|
|
374
|
+
return input instanceof Promise || input !== Promise.prototype && hasThen(input) && hasCatch(input);
|
|
375
|
+
}
|
|
376
|
+
__name(isThenable, "isThenable");
|
|
377
|
+
__name2(isThenable, "isThenable");
|
|
378
|
+
function makeObject(path, value, obj = {}) {
|
|
379
|
+
if (path.includes(".")) {
|
|
380
|
+
const route = path.split(".");
|
|
381
|
+
const lastKey = route.pop();
|
|
382
|
+
let reference = obj;
|
|
383
|
+
for (const key of route) {
|
|
384
|
+
if (!reference[key])
|
|
385
|
+
reference[key] = {};
|
|
386
|
+
reference = reference[key];
|
|
387
|
+
}
|
|
388
|
+
reference[lastKey] = value;
|
|
389
|
+
} else {
|
|
390
|
+
obj[path] = value;
|
|
391
|
+
}
|
|
392
|
+
return obj;
|
|
393
|
+
}
|
|
394
|
+
__name(makeObject, "makeObject");
|
|
395
|
+
__name2(makeObject, "makeObject");
|
|
396
|
+
function mergeDefault(base, overwrites) {
|
|
397
|
+
if (!overwrites)
|
|
398
|
+
return deepClone(base);
|
|
399
|
+
for (const [baseKey, baseValue] of Object.entries(base)) {
|
|
400
|
+
const overwritesValueAtBaseKey = Reflect.get(overwrites, baseKey);
|
|
401
|
+
if (typeof overwritesValueAtBaseKey === "undefined") {
|
|
402
|
+
Reflect.set(overwrites, baseKey, deepClone(baseValue));
|
|
403
|
+
} else if (isObject(overwritesValueAtBaseKey)) {
|
|
404
|
+
Reflect.set(overwrites, baseKey, mergeDefault(baseValue != null ? baseValue : {}, overwritesValueAtBaseKey));
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
return overwrites;
|
|
408
|
+
}
|
|
409
|
+
__name(mergeDefault, "mergeDefault");
|
|
410
|
+
__name2(mergeDefault, "mergeDefault");
|
|
411
|
+
function mergeObjects(objTarget, objSource) {
|
|
412
|
+
for (const [key, value] of Object.entries(objSource)) {
|
|
413
|
+
const targetValue = Reflect.get(objTarget, key);
|
|
414
|
+
if (isObject(value)) {
|
|
415
|
+
Reflect.set(objTarget, key, isObject(targetValue) ? mergeObjects(targetValue, value) : value);
|
|
416
|
+
} else if (!isObject(targetValue)) {
|
|
417
|
+
Reflect.set(objTarget, key, value);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return objTarget;
|
|
421
|
+
}
|
|
422
|
+
__name(mergeObjects, "mergeObjects");
|
|
423
|
+
__name2(mergeObjects, "mergeObjects");
|
|
424
|
+
function noop() {
|
|
425
|
+
}
|
|
426
|
+
__name(noop, "noop");
|
|
427
|
+
__name2(noop, "noop");
|
|
428
|
+
function objectToTuples(original, prefix = "") {
|
|
429
|
+
const entries = [];
|
|
430
|
+
for (const [key, value] of Object.entries(original)) {
|
|
431
|
+
if (isObject(value)) {
|
|
432
|
+
entries.push(...objectToTuples(value, `${prefix}${key}.`));
|
|
433
|
+
} else {
|
|
434
|
+
entries.push([`${prefix}${key}`, value]);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
return entries;
|
|
438
|
+
}
|
|
439
|
+
__name(objectToTuples, "objectToTuples");
|
|
440
|
+
__name2(objectToTuples, "objectToTuples");
|
|
441
|
+
function parseURL(url) {
|
|
442
|
+
try {
|
|
443
|
+
return new URL(url);
|
|
444
|
+
} catch {
|
|
445
|
+
return null;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
__name(parseURL, "parseURL");
|
|
449
|
+
__name2(parseURL, "parseURL");
|
|
450
|
+
function partition(array, predicate) {
|
|
451
|
+
if (!Array.isArray(array))
|
|
452
|
+
throw new TypeError("entries must be an array.");
|
|
453
|
+
if (!isFunction(predicate))
|
|
454
|
+
throw new TypeError("predicate must be an function that returns a boolean value.");
|
|
455
|
+
const partitionOne = [];
|
|
456
|
+
const partitionTwo = [];
|
|
457
|
+
for (let i = 0; i < array.length; i++) {
|
|
458
|
+
if (predicate(array[i], i)) {
|
|
459
|
+
partitionOne.push(array[i]);
|
|
460
|
+
} else {
|
|
461
|
+
partitionTwo.push(array[i]);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return [partitionOne, partitionTwo];
|
|
465
|
+
}
|
|
466
|
+
__name(partition, "partition");
|
|
467
|
+
__name2(partition, "partition");
|
|
468
|
+
function range(min, max, step) {
|
|
469
|
+
return new Array(Math.floor((max - min) / step) + 1).fill(0).map((_val, i) => min + i * step);
|
|
470
|
+
}
|
|
471
|
+
__name(range, "range");
|
|
472
|
+
__name2(range, "range");
|
|
473
|
+
var REGEXPESC = /[-/\\^$*+?.()|[\]{}]/g;
|
|
474
|
+
function regExpEsc(str) {
|
|
475
|
+
return str.replace(REGEXPESC, "\\$&");
|
|
476
|
+
}
|
|
477
|
+
__name(regExpEsc, "regExpEsc");
|
|
478
|
+
__name2(regExpEsc, "regExpEsc");
|
|
479
|
+
function roundNumber(num, scale = 0) {
|
|
480
|
+
if (!num.toString().includes("e")) {
|
|
481
|
+
return Number(`${Math.round(Number(`${num}e+${scale}`))}e-${scale}`);
|
|
482
|
+
}
|
|
483
|
+
const arr = `${num}`.split("e");
|
|
484
|
+
let sig = "";
|
|
485
|
+
if (Number(arr[1]) + scale > 0) {
|
|
486
|
+
sig = "+";
|
|
487
|
+
}
|
|
488
|
+
return Number(`${Math.round(Number(`${Number(arr[0])}e${sig}${Number(arr[1]) + scale}`))}e-${scale}`);
|
|
489
|
+
}
|
|
490
|
+
__name(roundNumber, "roundNumber");
|
|
491
|
+
__name2(roundNumber, "roundNumber");
|
|
492
|
+
var TO_TITLE_CASE = /[A-Za-zÀ-ÖØ-öø-ÿ]\S*/g;
|
|
493
|
+
var baseVariants = {
|
|
494
|
+
textchannel: "TextChannel",
|
|
495
|
+
voicechannel: "VoiceChannel",
|
|
496
|
+
categorychannel: "CategoryChannel",
|
|
497
|
+
guildmember: "GuildMember"
|
|
498
|
+
};
|
|
499
|
+
function toTitleCase(str, options = {}) {
|
|
500
|
+
const { additionalVariants = {}, caseSensitive } = options;
|
|
501
|
+
const titleCaseVariants = {
|
|
502
|
+
...baseVariants,
|
|
503
|
+
...caseSensitive ? additionalVariants : Object.entries(additionalVariants).reduce((variants, [key, variant]) => ({ ...variants, [key.toLowerCase()]: variant }), {})
|
|
504
|
+
};
|
|
505
|
+
return str.replace(TO_TITLE_CASE, (txt) => {
|
|
506
|
+
var _a;
|
|
507
|
+
return (_a = titleCaseVariants[caseSensitive ? txt : txt.toLowerCase()]) != null ? _a : txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase();
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
__name(toTitleCase, "toTitleCase");
|
|
511
|
+
__name2(toTitleCase, "toTitleCase");
|
|
512
|
+
function tryParse(value) {
|
|
513
|
+
try {
|
|
514
|
+
return JSON.parse(value);
|
|
515
|
+
} catch (err) {
|
|
516
|
+
return value;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
__name(tryParse, "tryParse");
|
|
520
|
+
__name2(tryParse, "tryParse");
|
|
521
|
+
|
|
522
|
+
// ../time-utilities/dist/index.mjs
|
|
523
|
+
var __defProp3 = Object.defineProperty;
|
|
524
|
+
var __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, "__defNormalProp");
|
|
525
|
+
var __name3 = /* @__PURE__ */ __name((target, value) => __defProp3(target, "name", { value, configurable: true }), "__name");
|
|
75
526
|
var __publicField2 = /* @__PURE__ */ __name((obj, key, value) => {
|
|
76
527
|
__defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
77
528
|
return value;
|
|
78
529
|
}, "__publicField");
|
|
530
|
+
var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
|
|
531
|
+
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
532
|
+
var tokens = /* @__PURE__ */ new Map([
|
|
533
|
+
["Y", 4],
|
|
534
|
+
["Q", 1],
|
|
535
|
+
["M", 4],
|
|
536
|
+
["D", 4],
|
|
537
|
+
["d", 4],
|
|
538
|
+
["X", 1],
|
|
539
|
+
["x", 1],
|
|
540
|
+
["H", 2],
|
|
541
|
+
["h", 2],
|
|
542
|
+
["a", 1],
|
|
543
|
+
["A", 1],
|
|
544
|
+
["m", 2],
|
|
545
|
+
["s", 2],
|
|
546
|
+
["S", 3],
|
|
547
|
+
["Z", 2],
|
|
548
|
+
["l", 4],
|
|
549
|
+
["L", 4],
|
|
550
|
+
["T", 1],
|
|
551
|
+
["t", 1]
|
|
552
|
+
]);
|
|
553
|
+
var partRegex = /^(?:(\*)|(\d+)(?:-(\d+))?)(?:\/(\d+))?$/;
|
|
554
|
+
var wildcardRegex = /\bh\b|\B\?\B/g;
|
|
555
|
+
var allowedNum = [
|
|
556
|
+
[0, 59],
|
|
557
|
+
[0, 23],
|
|
558
|
+
[1, 31],
|
|
559
|
+
[1, 12],
|
|
560
|
+
[0, 6]
|
|
561
|
+
];
|
|
562
|
+
var predefined = {
|
|
563
|
+
"@annually": "0 0 1 1 *",
|
|
564
|
+
"@yearly": "0 0 1 1 *",
|
|
565
|
+
"@monthly": "0 0 1 * *",
|
|
566
|
+
"@weekly": "0 0 * * 0",
|
|
567
|
+
"@daily": "0 0 * * *",
|
|
568
|
+
"@hourly": "0 * * * *"
|
|
569
|
+
};
|
|
79
570
|
var cronTokens = {
|
|
80
571
|
jan: 1,
|
|
81
572
|
feb: 2,
|
|
@@ -128,6 +619,90 @@ var SapphireRatelimits = (() => {
|
|
|
128
619
|
DEFAULT: "seconds"
|
|
129
620
|
}
|
|
130
621
|
};
|
|
622
|
+
var DEFAULT_SEPARATORS = {
|
|
623
|
+
left: " ",
|
|
624
|
+
right: " "
|
|
625
|
+
};
|
|
626
|
+
var Cron = /* @__PURE__ */ __name(class {
|
|
627
|
+
constructor(cron) {
|
|
628
|
+
__publicField2(this, "cron");
|
|
629
|
+
__publicField2(this, "normalized");
|
|
630
|
+
__publicField2(this, "minutes");
|
|
631
|
+
__publicField2(this, "hours");
|
|
632
|
+
__publicField2(this, "days");
|
|
633
|
+
__publicField2(this, "months");
|
|
634
|
+
__publicField2(this, "dows");
|
|
635
|
+
this.cron = cron.toLowerCase();
|
|
636
|
+
this.normalized = Cron.normalize(this.cron);
|
|
637
|
+
[this.minutes, this.hours, this.days, this.months, this.dows] = Cron.parseString(this.normalized);
|
|
638
|
+
}
|
|
639
|
+
next(outset = new Date(), origin = true) {
|
|
640
|
+
if (!this.days.includes(outset.getUTCDate()) || !this.months.includes(outset.getUTCMonth() + 1) || !this.dows.includes(outset.getUTCDay())) {
|
|
641
|
+
return this.next(new Date(outset.getTime() + 864e5), false);
|
|
642
|
+
}
|
|
643
|
+
if (!origin)
|
|
644
|
+
return new Date(Date.UTC(outset.getUTCFullYear(), outset.getUTCMonth(), outset.getUTCDate(), this.hours[0], this.minutes[0]));
|
|
645
|
+
const now = new Date(outset.getTime() + 6e4);
|
|
646
|
+
for (const hour of this.hours) {
|
|
647
|
+
if (hour < now.getUTCHours())
|
|
648
|
+
continue;
|
|
649
|
+
for (const minute of this.minutes) {
|
|
650
|
+
if (hour === now.getUTCHours() && minute < now.getUTCMinutes())
|
|
651
|
+
continue;
|
|
652
|
+
return new Date(Date.UTC(outset.getUTCFullYear(), outset.getUTCMonth(), outset.getUTCDate(), hour, minute));
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
return this.next(new Date(outset.getTime() + 864e5), false);
|
|
656
|
+
}
|
|
657
|
+
static normalize(cron) {
|
|
658
|
+
if (Reflect.has(predefined, cron))
|
|
659
|
+
return Reflect.get(predefined, cron);
|
|
660
|
+
const now = new Date();
|
|
661
|
+
cron = cron.split(" ").map((val, i) => val.replace(wildcardRegex, (match) => {
|
|
662
|
+
if (match === "h")
|
|
663
|
+
return (Math.floor(Math.random() * allowedNum[i][1]) + allowedNum[i][0]).toString();
|
|
664
|
+
if (match === "?") {
|
|
665
|
+
switch (i) {
|
|
666
|
+
case 0:
|
|
667
|
+
return now.getUTCMinutes().toString();
|
|
668
|
+
case 1:
|
|
669
|
+
return now.getUTCHours().toString();
|
|
670
|
+
case 2:
|
|
671
|
+
return now.getUTCDate().toString();
|
|
672
|
+
case 3:
|
|
673
|
+
return now.getUTCMonth().toString();
|
|
674
|
+
case 4:
|
|
675
|
+
return now.getUTCDay().toString();
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
return match;
|
|
679
|
+
})).join(" ");
|
|
680
|
+
return cron.replace(tokensRegex, (match) => String(Reflect.get(cronTokens, match)));
|
|
681
|
+
}
|
|
682
|
+
static parseString(cron) {
|
|
683
|
+
const parts = cron.split(" ");
|
|
684
|
+
if (parts.length !== 5)
|
|
685
|
+
throw new Error("Invalid Cron Provided");
|
|
686
|
+
return parts.map((part, i) => Cron.parsePart(part, i));
|
|
687
|
+
}
|
|
688
|
+
static parsePart(cronPart, id) {
|
|
689
|
+
if (cronPart.includes(",")) {
|
|
690
|
+
const res = [];
|
|
691
|
+
for (const part of cronPart.split(","))
|
|
692
|
+
res.push(...Cron.parsePart(part, id));
|
|
693
|
+
return [...new Set(res)].sort((a, b) => a - b);
|
|
694
|
+
}
|
|
695
|
+
const [, wild, minStr, maxStr, step] = partRegex.exec(cronPart);
|
|
696
|
+
let [min, max] = [parseInt(minStr, 10), parseInt(maxStr, 10)];
|
|
697
|
+
if (wild)
|
|
698
|
+
[min, max] = allowedNum[id];
|
|
699
|
+
else if (!max && !step)
|
|
700
|
+
return [min];
|
|
701
|
+
[min, max] = [min, max || allowedNum[id][1]].sort((a, b) => a - b);
|
|
702
|
+
return range(min, max, parseInt(step, 10) || 1);
|
|
703
|
+
}
|
|
704
|
+
}, "Cron");
|
|
705
|
+
__name3(Cron, "Cron");
|
|
131
706
|
var tokens2 = /* @__PURE__ */ new Map([
|
|
132
707
|
["nanosecond", 1 / 1e6],
|
|
133
708
|
["nanoseconds", 1 / 1e6],
|
|
@@ -168,7 +743,7 @@ var SapphireRatelimits = (() => {
|
|
|
168
743
|
["yrs", 1e3 * 60 * 60 * 24 * 365.25],
|
|
169
744
|
["y", 1e3 * 60 * 60 * 24 * 365.25]
|
|
170
745
|
]);
|
|
171
|
-
var _Duration = class {
|
|
746
|
+
var _Duration = /* @__PURE__ */ __name(class {
|
|
172
747
|
constructor(pattern) {
|
|
173
748
|
__publicField2(this, "offset");
|
|
174
749
|
this.offset = _Duration.parse(pattern.toLowerCase());
|
|
@@ -192,8 +767,9 @@ var SapphireRatelimits = (() => {
|
|
|
192
767
|
});
|
|
193
768
|
return valid ? result : NaN;
|
|
194
769
|
}
|
|
195
|
-
};
|
|
770
|
+
}, "_Duration");
|
|
196
771
|
var Duration = _Duration;
|
|
772
|
+
__name3(Duration, "Duration");
|
|
197
773
|
__publicField2(Duration, "kPatternRegex", /(-?\d*\.?\d+(?:e[-+]?\d+)?)\s*([a-zμ]*)/gi);
|
|
198
774
|
__publicField2(Duration, "kCommaRegex", /,/g);
|
|
199
775
|
__publicField2(Duration, "kAanRegex", /\ban?\b/gi);
|
|
@@ -206,7 +782,40 @@ var SapphireRatelimits = (() => {
|
|
|
206
782
|
["minute", 1e3 * 60],
|
|
207
783
|
["second", 1e3]
|
|
208
784
|
];
|
|
209
|
-
var
|
|
785
|
+
var DurationFormatter = /* @__PURE__ */ __name(class {
|
|
786
|
+
constructor(units = DEFAULT_UNITS) {
|
|
787
|
+
this.units = units;
|
|
788
|
+
}
|
|
789
|
+
format(duration, precision = 7, {
|
|
790
|
+
left: leftSeparator = DEFAULT_SEPARATORS.left,
|
|
791
|
+
right: rightSeparator = DEFAULT_SEPARATORS.right
|
|
792
|
+
} = DEFAULT_SEPARATORS) {
|
|
793
|
+
const output = [];
|
|
794
|
+
const negative = duration < 0;
|
|
795
|
+
if (negative)
|
|
796
|
+
duration *= -1;
|
|
797
|
+
for (const [type, timeDuration] of kTimeDurations) {
|
|
798
|
+
const substraction = duration / timeDuration;
|
|
799
|
+
if (substraction < 1)
|
|
800
|
+
continue;
|
|
801
|
+
const floored = Math.floor(substraction);
|
|
802
|
+
duration -= floored * timeDuration;
|
|
803
|
+
output.push(addUnit(floored, this.units[type], leftSeparator));
|
|
804
|
+
if (output.length >= precision)
|
|
805
|
+
break;
|
|
806
|
+
}
|
|
807
|
+
return `${negative ? "-" : ""}${output.join(rightSeparator) || addUnit(0, this.units.second, leftSeparator)}`;
|
|
808
|
+
}
|
|
809
|
+
}, "DurationFormatter");
|
|
810
|
+
__name3(DurationFormatter, "DurationFormatter");
|
|
811
|
+
function addUnit(time, unit, separator) {
|
|
812
|
+
if (Reflect.has(unit, time))
|
|
813
|
+
return `${time}${separator}${Reflect.get(unit, time)}`;
|
|
814
|
+
return `${time}${separator}${unit.DEFAULT}`;
|
|
815
|
+
}
|
|
816
|
+
__name(addUnit, "addUnit");
|
|
817
|
+
__name3(addUnit, "addUnit");
|
|
818
|
+
var TimerManager = /* @__PURE__ */ __name(class extends null {
|
|
210
819
|
static setTimeout(fn, delay, ...args) {
|
|
211
820
|
const timeout = setTimeout(() => {
|
|
212
821
|
this.storedTimeouts.delete(timeout);
|
|
@@ -236,9 +845,167 @@ var SapphireRatelimits = (() => {
|
|
|
236
845
|
this.storedTimeouts.clear();
|
|
237
846
|
this.storedIntervals.clear();
|
|
238
847
|
}
|
|
239
|
-
};
|
|
848
|
+
}, "TimerManager");
|
|
849
|
+
__name3(TimerManager, "TimerManager");
|
|
240
850
|
__publicField2(TimerManager, "storedTimeouts", /* @__PURE__ */ new Set());
|
|
241
851
|
__publicField2(TimerManager, "storedIntervals", /* @__PURE__ */ new Set());
|
|
852
|
+
var tokenResolvers = /* @__PURE__ */ new Map([
|
|
853
|
+
["Y", (time) => String(time.getFullYear()).slice(2)],
|
|
854
|
+
["YY", (time) => String(time.getFullYear()).slice(2)],
|
|
855
|
+
["YYY", (time) => String(time.getFullYear())],
|
|
856
|
+
["YYYY", (time) => String(time.getFullYear())],
|
|
857
|
+
["Q", (time) => String((time.getMonth() + 1) / 3)],
|
|
858
|
+
["M", (time) => String(time.getMonth() + 1)],
|
|
859
|
+
["MM", (time) => String(time.getMonth() + 1).padStart(2, "0")],
|
|
860
|
+
["MMM", (time) => months[time.getMonth()]],
|
|
861
|
+
["MMMM", (time) => months[time.getMonth()]],
|
|
862
|
+
["D", (time) => String(time.getDate())],
|
|
863
|
+
["DD", (time) => String(time.getDate()).padStart(2, "0")],
|
|
864
|
+
["DDD", (time) => String(Math.floor((time.getTime() - new Date(time.getFullYear(), 0, 0).getTime()) / 864e5))],
|
|
865
|
+
["DDDD", (time) => String(Math.floor((time.getTime() - new Date(time.getFullYear(), 0, 0).getTime()) / 864e5))],
|
|
866
|
+
[
|
|
867
|
+
"d",
|
|
868
|
+
(time) => {
|
|
869
|
+
const day = String(time.getDate());
|
|
870
|
+
if (day !== "11" && day.endsWith("1"))
|
|
871
|
+
return `${day}st`;
|
|
872
|
+
if (day !== "12" && day.endsWith("2"))
|
|
873
|
+
return `${day}nd`;
|
|
874
|
+
if (day !== "13" && day.endsWith("3"))
|
|
875
|
+
return `${day}rd`;
|
|
876
|
+
return `${day}th`;
|
|
877
|
+
}
|
|
878
|
+
],
|
|
879
|
+
["dd", (time) => days[time.getDay()].slice(0, 2)],
|
|
880
|
+
["ddd", (time) => days[time.getDay()].slice(0, 3)],
|
|
881
|
+
["dddd", (time) => days[time.getDay()]],
|
|
882
|
+
["X", (time) => String(time.valueOf() / 1e3)],
|
|
883
|
+
["x", (time) => String(time.valueOf())],
|
|
884
|
+
["H", (time) => String(time.getHours())],
|
|
885
|
+
["HH", (time) => String(time.getHours()).padStart(2, "0")],
|
|
886
|
+
["h", (time) => String(time.getHours() % 12 || 12)],
|
|
887
|
+
["hh", (time) => String(time.getHours() % 12 || 12).padStart(2, "0")],
|
|
888
|
+
["a", (time) => time.getHours() < 12 ? "am" : "pm"],
|
|
889
|
+
["A", (time) => time.getHours() < 12 ? "AM" : "PM"],
|
|
890
|
+
["m", (time) => String(time.getMinutes())],
|
|
891
|
+
["mm", (time) => String(time.getMinutes()).padStart(2, "0")],
|
|
892
|
+
["s", (time) => String(time.getSeconds())],
|
|
893
|
+
["ss", (time) => String(time.getSeconds()).padStart(2, "0")],
|
|
894
|
+
["S", (time) => String(time.getMilliseconds())],
|
|
895
|
+
["SS", (time) => String(time.getMilliseconds()).padStart(2, "0")],
|
|
896
|
+
["SSS", (time) => String(time.getMilliseconds()).padStart(3, "0")],
|
|
897
|
+
["T", (time) => `${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")} ${time.getHours() < 12 ? "AM" : "PM"}`],
|
|
898
|
+
[
|
|
899
|
+
"t",
|
|
900
|
+
(time) => `${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")}:${String(time.getSeconds()).padStart(2, "0")} ${time.getHours() < 12 ? "am" : "pm"}`
|
|
901
|
+
],
|
|
902
|
+
["L", (time) => `${String(time.getMonth() + 1).padStart(2, "0")}/${String(time.getDate()).padStart(2, "0")}/${String(time.getFullYear())}`],
|
|
903
|
+
["l", (time) => `${String(time.getMonth() + 1)}/${String(time.getDate()).padStart(2, "0")}/${String(time.getFullYear())}`],
|
|
904
|
+
["LL", (time) => `${months[time.getMonth()]} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())}`],
|
|
905
|
+
["ll", (time) => `${months[time.getMonth()].slice(0, 3)} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())}`],
|
|
906
|
+
[
|
|
907
|
+
"LLL",
|
|
908
|
+
(time) => `${months[time.getMonth()]} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())} ${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")} ${time.getHours() < 12 ? "AM" : "PM"}`
|
|
909
|
+
],
|
|
910
|
+
[
|
|
911
|
+
"lll",
|
|
912
|
+
(time) => `${months[time.getMonth()].slice(0, 3)} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())} ${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")} ${time.getHours() < 12 ? "AM" : "PM"}`
|
|
913
|
+
],
|
|
914
|
+
[
|
|
915
|
+
"LLLL",
|
|
916
|
+
(time) => `${days[time.getDay()]}, ${months[time.getMonth()]} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())} ${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")} ${time.getHours() < 12 ? "AM" : "PM"}`
|
|
917
|
+
],
|
|
918
|
+
[
|
|
919
|
+
"llll",
|
|
920
|
+
(time) => `${days[time.getDay()].slice(0, 3)} ${months[time.getMonth()].slice(0, 3)} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())} ${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")} ${time.getHours() < 12 ? "AM" : "PM"}`
|
|
921
|
+
],
|
|
922
|
+
[
|
|
923
|
+
"Z",
|
|
924
|
+
(time) => {
|
|
925
|
+
const offset = time.getTimezoneOffset();
|
|
926
|
+
const unsigned = offset >= 0;
|
|
927
|
+
const absolute = Math.abs(offset);
|
|
928
|
+
return `${unsigned ? "+" : "-"}${String(Math.floor(absolute / 60)).padStart(2, "0")}:${String(absolute % 60).padStart(2, "0")}`;
|
|
929
|
+
}
|
|
930
|
+
],
|
|
931
|
+
[
|
|
932
|
+
"ZZ",
|
|
933
|
+
(time) => {
|
|
934
|
+
const offset = time.getTimezoneOffset();
|
|
935
|
+
const unsigned = offset >= 0;
|
|
936
|
+
const absolute = Math.abs(offset);
|
|
937
|
+
return `${unsigned ? "+" : "-"}${String(Math.floor(absolute / 60)).padStart(2, "0")}:${String(absolute % 60).padStart(2, "0")}`;
|
|
938
|
+
}
|
|
939
|
+
]
|
|
940
|
+
]);
|
|
941
|
+
var Timestamp = /* @__PURE__ */ __name(class {
|
|
942
|
+
constructor(pattern) {
|
|
943
|
+
__publicField2(this, "pattern");
|
|
944
|
+
__publicField2(this, "template");
|
|
945
|
+
this.pattern = pattern;
|
|
946
|
+
this.template = Timestamp.parse(pattern);
|
|
947
|
+
}
|
|
948
|
+
display(time = new Date()) {
|
|
949
|
+
return Timestamp.display(this.template, time);
|
|
950
|
+
}
|
|
951
|
+
displayUTC(time) {
|
|
952
|
+
return Timestamp.display(this.template, Timestamp.utc(time));
|
|
953
|
+
}
|
|
954
|
+
edit(pattern) {
|
|
955
|
+
this.pattern = pattern;
|
|
956
|
+
this.template = Timestamp.parse(pattern);
|
|
957
|
+
return this;
|
|
958
|
+
}
|
|
959
|
+
toString() {
|
|
960
|
+
return this.display();
|
|
961
|
+
}
|
|
962
|
+
static displayArbitrary(pattern, time = new Date()) {
|
|
963
|
+
return Timestamp.display(Timestamp.parse(pattern), time);
|
|
964
|
+
}
|
|
965
|
+
static displayUTCArbitrary(pattern, time = new Date()) {
|
|
966
|
+
return Timestamp.display(Timestamp.parse(pattern), Timestamp.utc(time));
|
|
967
|
+
}
|
|
968
|
+
static utc(time = new Date()) {
|
|
969
|
+
time = Timestamp.resolveDate(time);
|
|
970
|
+
return new Date(time.valueOf() + time.getTimezoneOffset() * 6e4);
|
|
971
|
+
}
|
|
972
|
+
static display(template, time) {
|
|
973
|
+
let output = "";
|
|
974
|
+
const parsedTime = Timestamp.resolveDate(time);
|
|
975
|
+
for (const { content, type } of template)
|
|
976
|
+
output += content || tokenResolvers.get(type)(parsedTime);
|
|
977
|
+
return output;
|
|
978
|
+
}
|
|
979
|
+
static parse(pattern) {
|
|
980
|
+
const template = [];
|
|
981
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
982
|
+
let current = "";
|
|
983
|
+
const currentChar = pattern[i];
|
|
984
|
+
const tokenMax = tokens.get(currentChar);
|
|
985
|
+
if (typeof tokenMax === "number") {
|
|
986
|
+
current += currentChar;
|
|
987
|
+
while (pattern[i + 1] === currentChar && current.length < tokenMax)
|
|
988
|
+
current += pattern[++i];
|
|
989
|
+
template.push({ type: current, content: null });
|
|
990
|
+
} else if (currentChar === "[") {
|
|
991
|
+
while (i + 1 < pattern.length && pattern[i + 1] !== "]")
|
|
992
|
+
current += pattern[++i];
|
|
993
|
+
i++;
|
|
994
|
+
template.push({ type: "literal", content: current || "[" });
|
|
995
|
+
} else {
|
|
996
|
+
current += currentChar;
|
|
997
|
+
while (i + 1 < pattern.length && !tokens.has(pattern[i + 1]) && pattern[i + 1] !== "[")
|
|
998
|
+
current += pattern[++i];
|
|
999
|
+
template.push({ type: "literal", content: current });
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
return template;
|
|
1003
|
+
}
|
|
1004
|
+
static resolveDate(time) {
|
|
1005
|
+
return time instanceof Date ? time : new Date(time);
|
|
1006
|
+
}
|
|
1007
|
+
}, "Timestamp");
|
|
1008
|
+
__name3(Timestamp, "Timestamp");
|
|
242
1009
|
|
|
243
1010
|
// src/lib/RateLimitManager.ts
|
|
244
1011
|
var _RateLimitManager = class extends Map {
|
|
@@ -274,7 +1041,23 @@ var SapphireRatelimits = (() => {
|
|
|
274
1041
|
}
|
|
275
1042
|
};
|
|
276
1043
|
var RateLimitManager = _RateLimitManager;
|
|
1044
|
+
__name(RateLimitManager, "RateLimitManager");
|
|
277
1045
|
__publicField(RateLimitManager, "sweepIntervalDuration", 3e4);
|
|
278
1046
|
return __toCommonJS(src_exports);
|
|
279
1047
|
})();
|
|
1048
|
+
/**
|
|
1049
|
+
* Split a string by its latest space character in a range from the character 0 to the selected one.
|
|
1050
|
+
* @param str The text to split.
|
|
1051
|
+
* @param length The length of the desired string.
|
|
1052
|
+
* @param char The character to split with
|
|
1053
|
+
* @copyright 2019 Antonio Román
|
|
1054
|
+
* @license Apache-2.0
|
|
1055
|
+
*/
|
|
1056
|
+
/**
|
|
1057
|
+
* Split a text by its latest space character in a range from the character 0 to the selected one.
|
|
1058
|
+
* @param str The text to split.
|
|
1059
|
+
* @param length The length of the desired string.
|
|
1060
|
+
* @copyright 2019 Antonio Román
|
|
1061
|
+
* @license Apache-2.0
|
|
1062
|
+
*/
|
|
280
1063
|
//# sourceMappingURL=index.global.js.map
|