@sapphire/framework
Version:
Discord bot framework built for advanced and amazing bots.
40 lines (38 loc) • 1.77 kB
JavaScript
;
const require_lib_types_Enums = require('../types/Enums.cjs');
require('../utils/preconditions/PreconditionContainerArray.cjs');
let __sapphire_pieces = require("@sapphire/pieces");
//#region src/lib/precondition-resolvers/cooldown.ts
/**
* Appends the `Cooldown` precondition when {@link Command.Options.cooldownLimit} and
* {@link Command.Options.cooldownDelay} are both non-zero.
*
* @param command The command to parse cooldowns for.
* @param cooldownLimit The cooldown limit to use.
* @param cooldownDelay The cooldown delay to use.
* @param cooldownScope The cooldown scope to use.
* @param cooldownFilteredUsers The cooldown filtered users to use.
* @param preconditionContainerArray The precondition container array to append the precondition to.
*/
function parseConstructorPreConditionsCooldown(command, cooldownLimit, cooldownDelay, cooldownScope, cooldownFilteredUsers, preconditionContainerArray) {
const { defaultCooldown } = __sapphire_pieces.container.client.options;
const filtered = defaultCooldown?.filteredCommands?.includes(command.name) ?? false;
const limit = cooldownLimit ?? (filtered ? 0 : defaultCooldown?.limit ?? 1);
const delay = cooldownDelay ?? (filtered ? 0 : defaultCooldown?.delay ?? 0);
if (limit && delay) {
const scope = cooldownScope ?? defaultCooldown?.scope ?? require_lib_types_Enums.BucketScope.User;
const filteredUsers = cooldownFilteredUsers ?? defaultCooldown?.filteredUsers;
preconditionContainerArray.append({
name: require_lib_types_Enums.CommandPreConditions.Cooldown,
context: {
scope,
limit,
delay,
filteredUsers
}
});
}
}
//#endregion
exports.parseConstructorPreConditionsCooldown = parseConstructorPreConditionsCooldown;
//# sourceMappingURL=cooldown.cjs.map