New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More β†’
Socket
Sign inDemoInstall
Socket

@sapphire/framework

Package Overview
Dependencies
Maintainers
3
Versions
860
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sapphire/framework - npm Package Compare versions

Comparing version 2.0.0-next.d8053045.0 to 2.0.0-next.db6febd5.0

dist/arguments/CoreGuildCategoryChannel.js

18

dist/arguments/CoreBoolean.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreArgument = void 0;
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");
const truths = ['1', 'true', '+', 't', 'yes', 'y'];
const falses = ['0', 'false', '-', 'f', 'no', 'n'];
class CoreArgument extends Argument_1.Argument {

@@ -12,8 +11,11 @@ constructor(context) {

run(parameter, context) {
const boolean = parameter.toLowerCase();
if (truths.includes(boolean))
return this.ok(true);
if (falses.includes(boolean))
return this.ok(false);
return this.error({ parameter, message: 'The argument did not resolve to a boolean.', context });
const resolved = (0, resolvers_1.resolveBoolean)(parameter, { truths: context.truths, falses: context.falses });
if (resolved.success)
return this.ok(resolved.value);
return this.error({
parameter,
identifier: resolved.error,
message: 'The argument did not resolve to a boolean.',
context
});
}

@@ -20,0 +22,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreArgument = void 0;
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");

@@ -10,10 +11,11 @@ class CoreArgument extends Argument_1.Argument {

run(parameter, context) {
const channel = (context.message.guild ? context.message.guild.channels : this.container.client.channels).cache.get(parameter);
return channel
? this.ok(channel)
: this.error({
parameter,
message: 'The argument did not resolve to a channel.',
context: { ...context, channel }
});
const resolved = (0, resolvers_1.resolveChannel)(parameter, context.message);
if (resolved.success)
return this.ok(resolved.value);
return this.error({
parameter,
identifier: resolved.error,
message: 'The argument did not resolve to a channel.',
context
});
}

@@ -20,0 +22,0 @@ }

@@ -5,2 +5,3 @@ "use strict";

require("../lib/errors/Identifiers");
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");

@@ -10,20 +11,18 @@ class CoreArgument extends Argument_1.Argument {

super(context, { name: 'date' });
this.messages = {
["dateTooEarly" /* ArgumentDateTooEarly */]: ({ minimum }) => `The given date must be after ${new Date(minimum).toISOString()}.`,
["dateTooFar" /* ArgumentDateTooFar */]: ({ maximum }) => `The given date must be before ${new Date(maximum).toISOString()}.`,
["dateError" /* ArgumentDateError */]: () => 'The argument did not resolve to a date.'
};
}
run(parameter, context) {
const parsed = new Date(parameter);
const time = parsed.getTime();
if (Number.isNaN(time)) {
return this.error({
parameter,
message: 'The argument did not resolve to a valid date.',
context
});
}
if (typeof context.minimum === 'number' && time < context.minimum) {
return this.error({ parameter, identifier: "dateTooSmall" /* ArgumentDateTooSmall */, message: 'The argument is too small.', context });
}
if (typeof context.maximum === 'number' && time > context.maximum) {
return this.error({ parameter, identifier: "dateTooBig" /* ArgumentDateTooBig */, message: 'The argument is too big.', context });
}
return this.ok(parsed);
const resolved = (0, resolvers_1.resolveDate)(parameter, { minimum: context.minimum, maximum: context.maximum });
if (resolved.success)
return this.ok(resolved.value);
return this.error({
parameter,
identifier: resolved.error,
message: this.messages[resolved.error](context),
context
});
}

@@ -30,0 +29,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreArgument = void 0;
const discord_js_utilities_1 = require("@sapphire/discord.js-utilities");
const ExtendedArgument_1 = require("../lib/structures/ExtendedArgument");
class CoreArgument extends ExtendedArgument_1.ExtendedArgument {
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");
class CoreArgument extends Argument_1.Argument {
constructor(context) {
super(context, { baseArgument: 'channel', name: 'dmChannel' });
super(context, { name: 'dmChannel' });
}
handle(channel, context) {
return discord_js_utilities_1.isDMChannel(channel)
? this.ok(channel)
: this.error({
parameter: context.parameter,
message: 'The argument did not resolve to a DM channel.',
context: { ...context, channel }
});
run(parameter, context) {
const resolved = (0, resolvers_1.resolveDMChannel)(parameter, context.message);
if (resolved.success)
return this.ok(resolved.value);
return this.error({
parameter,
identifier: resolved.error,
message: 'The argument did not resolve to a DM channel.',
context
});
}

@@ -19,0 +21,0 @@ }

@@ -5,2 +5,3 @@ "use strict";

require("../lib/errors/Identifiers");
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");

@@ -10,25 +11,18 @@ class CoreArgument extends Argument_1.Argument {

super(context, { name: 'float' });
this.messages = {
["floatTooSmall" /* ArgumentFloatTooSmall */]: ({ minimum }) => `The given number must be greater than ${minimum}.`,
["floatTooLarge" /* ArgumentFloatTooLarge */]: ({ maximum }) => `The given number must be less than ${maximum}.`,
["floatError" /* ArgumentFloatError */]: () => 'The argument did not resolve to a valid decimal.'
};
}
run(parameter, context) {
const parsed = Number(parameter);
if (Number.isNaN(parsed)) {
return this.error({ parameter, message: 'The argument did not resolve to a valid floating point number.', context });
}
if (typeof context.minimum === 'number' && parsed < context.minimum) {
return this.error({
parameter,
identifier: "floatTooSmall" /* ArgumentFloatTooSmall */,
message: `The argument must be greater than ${context.minimum}.`,
context
});
}
if (typeof context.maximum === 'number' && parsed > context.maximum) {
return this.error({
parameter,
identifier: "floatTooBig" /* ArgumentFloatTooBig */,
message: `The argument must be less than ${context.maximum}.`,
context
});
}
return this.ok(parsed);
const resolved = (0, resolvers_1.resolveFloat)(parameter, { minimum: context.minimum, maximum: context.maximum });
if (resolved.success)
return this.ok(resolved.value);
return this.error({
parameter,
identifier: resolved.error,
message: this.messages[resolved.error](context),
context
});
}

@@ -35,0 +29,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreArgument = void 0;
const discord_utilities_1 = require("@sapphire/discord-utilities");
require("../lib/errors/Identifiers");
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");

@@ -12,3 +12,2 @@ class CoreArgument extends Argument_1.Argument {

run(parameter, context) {
var _a;
const { guild } = context.message;

@@ -18,28 +17,19 @@ if (!guild) {

parameter,
identifier: "guildChannelMissingGuild" /* ArgumentGuildChannelMissingGuild */,
message: 'The argument must be run in a guild.',
context: { ...context, guild }
identifier: "guildChannelMissingGuildError" /* ArgumentGuildChannelMissingGuildError */,
message: 'This command can only be used in a server.',
context
});
}
const channel = (_a = this.resolveByID(parameter, guild)) !== null && _a !== void 0 ? _a : this.resolveByQuery(parameter, guild);
return channel
? this.ok(channel)
: this.error({
parameter,
message: 'The argument did not resolve to a guild channel.',
context: { ...context, guild }
});
const resolved = (0, resolvers_1.resolveGuildChannel)(parameter, guild);
if (resolved.success)
return this.ok(resolved.value);
return this.error({
parameter,
identifier: resolved.error,
message: 'The argument did not resolve to a valid server channel.',
context: { ...context, guild }
});
}
resolveByID(argument, guild) {
var _a, _b;
const channelID = (_a = discord_utilities_1.ChannelMentionRegex.exec(argument)) !== null && _a !== void 0 ? _a : discord_utilities_1.SnowflakeRegex.exec(argument);
return channelID ? (_b = guild.channels.cache.get(channelID[1])) !== null && _b !== void 0 ? _b : null : null;
}
resolveByQuery(argument, guild) {
var _a;
const lowerCaseArgument = argument.toLowerCase();
return (_a = guild.channels.cache.find((channel) => channel.name.toLowerCase() === lowerCaseArgument)) !== null && _a !== void 0 ? _a : null;
}
}
exports.CoreArgument = CoreArgument;
//# sourceMappingURL=CoreGuildChannel.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreArgument = void 0;
const url_1 = require("url");
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");

@@ -11,8 +11,11 @@ class CoreArgument extends Argument_1.Argument {

run(parameter, context) {
try {
return this.ok(new url_1.URL(parameter));
}
catch {
return this.error({ parameter, message: 'The argument did not resolve to a valid URL.', context });
}
const resolved = (0, resolvers_1.resolveHyperlink)(parameter);
if (resolved.success)
return this.ok(resolved.value);
return this.error({
parameter,
identifier: resolved.error,
message: 'The argument did not resolve to a valid URL.',
context
});
}

@@ -19,0 +22,0 @@ }

@@ -5,2 +5,3 @@ "use strict";

require("../lib/errors/Identifiers");
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");

@@ -10,29 +11,18 @@ class CoreArgument extends Argument_1.Argument {

super(context, { name: 'integer' });
this.messages = {
["integerTooSmall" /* ArgumentIntegerTooSmall */]: ({ minimum }) => `The given number must be greater than ${minimum}.`,
["integerTooLarge" /* ArgumentIntegerTooLarge */]: ({ maximum }) => `The given number must be less than ${maximum}.`,
["integerError" /* ArgumentIntegerError */]: () => 'The argument did not resolve to a valid number.'
};
}
run(parameter, context) {
const parsed = Number(parameter);
if (!Number.isInteger(parsed)) {
return this.error({
parameter,
message: 'The argument did not resolve to an integer.',
context
});
}
if (typeof context.minimum === 'number' && parsed < context.minimum) {
return this.error({
parameter,
identifier: "integerTooSmall" /* ArgumentIntegerTooSmall */,
message: `The argument must be greater than ${context.minimum}.`,
context
});
}
if (typeof context.maximum === 'number' && parsed > context.maximum) {
return this.error({
parameter,
identifier: "integerTooBig" /* ArgumentIntegerTooBig */,
message: `The argument must be less than ${context.maximum}.`,
context
});
}
return this.ok(parsed);
const resolved = (0, resolvers_1.resolveInteger)(parameter, { minimum: context.minimum, maximum: context.maximum });
if (resolved.success)
return this.ok(resolved.value);
return this.error({
parameter,
identifier: resolved.error,
message: this.messages[resolved.error](context),
context
});
}

@@ -39,0 +29,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreArgument = void 0;
const discord_utilities_1 = require("@sapphire/discord-utilities");
require("../lib/errors/Identifiers");
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");

@@ -12,3 +12,2 @@ class CoreArgument extends Argument_1.Argument {

async run(parameter, context) {
var _a;
const { guild } = context.message;

@@ -19,32 +18,18 @@ if (!guild) {

identifier: "memberMissingGuild" /* ArgumentMemberMissingGuild */,
message: 'The argument must be run on a guild.',
context: { ...context, guild }
message: 'This command can only be used in a server.',
context
});
}
const member = (_a = (await this.resolveByID(parameter, guild))) !== null && _a !== void 0 ? _a : (await this.resolveByQuery(parameter, guild));
return member
? this.ok(member)
: this.error({
parameter,
message: 'The argument did not resolve to a member.',
context: { ...context, guild }
});
const resolved = await (0, resolvers_1.resolveMember)(parameter, guild);
if (resolved.success)
return this.ok(resolved.value);
return this.error({
parameter,
identifier: resolved.error,
message: 'The given argument did not resolve to a server member.',
context: { ...context, guild }
});
}
async resolveByID(argument, guild) {
var _a;
const memberID = (_a = discord_utilities_1.UserOrMemberMentionRegex.exec(argument)) !== null && _a !== void 0 ? _a : discord_utilities_1.SnowflakeRegex.exec(argument);
return memberID ? guild.members.fetch(memberID[1]).catch(() => null) : null;
}
async resolveByQuery(argument, guild) {
var _a;
const members = await guild.members
.fetch({
query: argument,
limit: 1
})
.catch(() => null);
return (_a = members === null || members === void 0 ? void 0 : members.first()) !== null && _a !== void 0 ? _a : null;
}
}
exports.CoreArgument = CoreArgument;
//# sourceMappingURL=CoreMember.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreArgument = void 0;
const discord_js_utilities_1 = require("@sapphire/discord.js-utilities");
const discord_js_1 = require("discord.js");
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");

@@ -12,40 +11,15 @@ class CoreArgument extends Argument_1.Argument {

async run(parameter, context) {
var _a, _b;
const channel = (_a = context.channel) !== null && _a !== void 0 ? _a : context.message.channel;
const message = (_b = (await this.resolveByID(parameter, channel))) !== null && _b !== void 0 ? _b : (await this.resolveByLink(parameter, context));
return message
? this.ok(message)
: this.error({
parameter,
message: 'The argument did not resolve to a message.',
context: { ...context, channel }
});
const channel = context.channel ?? context.message.channel;
const resolved = await (0, resolvers_1.resolveMessage)(parameter, { message: context.message, channel: context.channel });
if (resolved.success)
return this.ok(resolved.value);
return this.error({
parameter,
identifier: resolved.error,
message: 'The given argument did not resolve to a message.',
context: { ...context, channel }
});
}
async resolveByID(argument, channel) {
return discord_js_utilities_1.SnowflakeRegex.test(argument) ? channel.messages.fetch(argument).catch(() => null) : null;
}
async resolveByLink(argument, { message }) {
var _a;
if (!message.guild)
return null;
const matches = discord_js_utilities_1.MessageLinkRegex.exec(argument);
if (!matches)
return null;
const [, guildID, channelID, messageID] = matches;
const guild = this.container.client.guilds.cache.get(guildID);
if (guild !== message.guild)
return null;
const channel = guild.channels.cache.get(channelID);
if (!channel)
return null;
if (!(discord_js_utilities_1.isNewsChannel(channel) || discord_js_utilities_1.isTextChannel(channel)))
return null;
if (!channel.viewable)
return null;
if (!((_a = channel.permissionsFor(message.author)) === null || _a === void 0 ? void 0 : _a.has(discord_js_1.Permissions.FLAGS.VIEW_CHANNEL)))
return null;
return channel.messages.fetch(messageID).catch(() => null);
}
}
exports.CoreArgument = CoreArgument;
//# sourceMappingURL=CoreMessage.js.map

@@ -5,2 +5,3 @@ "use strict";

require("../lib/errors/Identifiers");
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");

@@ -10,29 +11,18 @@ class CoreArgument extends Argument_1.Argument {

super(context, { name: 'number' });
this.messages = {
["numberTooSmall" /* ArgumentNumberTooSmall */]: ({ minimum }) => `The given number must be greater than ${minimum}.`,
["numberTooLarge" /* ArgumentNumberTooLarge */]: ({ maximum }) => `The given number must be less than ${maximum}.`,
["numberError" /* ArgumentNumberError */]: () => 'The argument did not resolve to a valid number.'
};
}
run(parameter, context) {
const parsed = Number(parameter);
if (Number.isNaN(parsed)) {
return this.error({
parameter,
message: 'The argument did not resolve to a valid number.',
context
});
}
if (typeof context.minimum === 'number' && parsed < context.minimum) {
return this.error({
parameter,
identifier: "numberTooSmall" /* ArgumentNumberTooSmall */,
message: `The argument must be greater than ${context.minimum}.`,
context
});
}
if (typeof context.maximum === 'number' && parsed > context.maximum) {
return this.error({
parameter,
identifier: "numberTooBig" /* ArgumentNumberTooBig */,
message: `The argument must be smaller than ${context.maximum}.`,
context
});
}
return this.ok(parsed);
const resolved = (0, resolvers_1.resolveNumber)(parameter, { minimum: context.minimum, maximum: context.maximum });
if (resolved.success)
return this.ok(resolved.value);
return this.error({
parameter,
identifier: resolved.error,
message: this.messages[resolved.error](context),
context
});
}

@@ -39,0 +29,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreArgument = void 0;
const discord_utilities_1 = require("@sapphire/discord-utilities");
require("../lib/errors/Identifiers");
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");

@@ -12,3 +12,2 @@ class CoreArgument extends Argument_1.Argument {

async run(parameter, context) {
var _a;
const { guild } = context.message;

@@ -19,21 +18,18 @@ if (!guild) {

identifier: "roleMissingGuild" /* ArgumentRoleMissingGuild */,
message: 'The argument must be run on a guild.',
message: 'This command can only be used in a server.',
context
});
}
const role = (_a = (await this.resolveByID(parameter, guild))) !== null && _a !== void 0 ? _a : this.resolveByQuery(parameter, guild);
return role ? this.ok(role) : this.error({ parameter, message: 'The argument did not resolve to a role.', context });
const resolved = await (0, resolvers_1.resolveRole)(parameter, guild);
if (resolved.success)
return this.ok(resolved.value);
return this.error({
parameter,
identifier: resolved.error,
message: 'The given argument did not resolve to a role.',
context: { ...context, guild }
});
}
async resolveByID(argument, guild) {
var _a;
const roleID = (_a = discord_utilities_1.RoleMentionRegex.exec(argument)) !== null && _a !== void 0 ? _a : discord_utilities_1.SnowflakeRegex.exec(argument);
return roleID ? guild.roles.fetch(roleID[1]).catch(() => null) : null;
}
resolveByQuery(argument, guild) {
var _a;
const lowerCaseArgument = argument.toLowerCase();
return (_a = guild.roles.cache.find((role) => role.name.toLowerCase() === lowerCaseArgument)) !== null && _a !== void 0 ? _a : null;
}
}
exports.CoreArgument = CoreArgument;
//# sourceMappingURL=CoreRole.js.map

@@ -5,2 +5,3 @@ "use strict";

require("../lib/errors/Identifiers");
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");

@@ -10,21 +11,17 @@ class CoreArgument extends Argument_1.Argument {

super(context, { name: 'string' });
this.messages = {
["stringTooShort" /* ArgumentStringTooShort */]: ({ minimum }) => `The argument must be longer than ${minimum} characters.`,
["stringTooLong" /* ArgumentStringTooLong */]: ({ maximum }) => `The argument must be shorter than ${maximum} characters.`
};
}
run(parameter, context) {
if (typeof context.minimum === 'number' && parameter.length < context.minimum) {
return this.error({
parameter,
identifier: "stringTooShort" /* ArgumentStringTooShort */,
message: `The argument must be longer than ${context.minimum} characters.`,
context
});
}
if (typeof context.maximum === 'number' && parameter.length > context.maximum) {
return this.error({
parameter,
identifier: "stringTooLong" /* ArgumentStringTooLong */,
message: `The argument must be shorter than ${context.maximum} characters.`,
context
});
}
return this.ok(parameter);
const resolved = (0, resolvers_1.resolveString)(parameter, { minimum: context?.minimum, maximum: context?.maximum });
if (resolved.success)
return this.ok(resolved.value);
return this.error({
parameter,
identifier: resolved.error,
message: this.messages[resolved.error](context),
context
});
}

@@ -31,0 +28,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreArgument = void 0;
const discord_utilities_1 = require("@sapphire/discord-utilities");
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");

@@ -11,6 +11,11 @@ class CoreArgument extends Argument_1.Argument {

async run(parameter, context) {
var _a;
const userID = (_a = discord_utilities_1.UserOrMemberMentionRegex.exec(parameter)) !== null && _a !== void 0 ? _a : discord_utilities_1.SnowflakeRegex.exec(parameter);
const user = userID ? await this.container.client.users.fetch(userID[1]).catch(() => null) : null;
return user ? this.ok(user) : this.error({ parameter, message: 'The argument did not resolve to a user.', context });
const resolved = await (0, resolvers_1.resolveUser)(parameter);
if (resolved.success)
return this.ok(resolved.value);
return this.error({
parameter,
identifier: resolved.error,
message: 'The given argument did not resolve to a Discord user.',
context
});
}

@@ -17,0 +22,0 @@ }

@@ -1,6 +0,6 @@

/* Version: 2.0.0-next.d8053045.0 - June 30, 2021 20:23:16 */
/* Version: 2.0.0-next.db6febd5.0 - September 9, 2021 18:18:42 */
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = exports.Store = exports.Piece = exports.MissingExportsError = exports.LoaderError = exports.container = exports.AliasStore = exports.AliasPiece = void 0;
exports.version = exports.ClientPermissionsCorePrecondition = exports.Resolvers = exports.StoreRegistry = exports.Store = exports.Piece = exports.MissingExportsError = exports.LoaderError = exports.container = exports.AliasStore = exports.AliasPiece = void 0;
const tslib_1 = require("tslib");

@@ -15,34 +15,38 @@ var pieces_1 = require("@sapphire/pieces");

Object.defineProperty(exports, "Store", { enumerable: true, get: function () { return pieces_1.Store; } });
tslib_1.__exportStar(require("./lib/errors/ArgumentError"), exports);
tslib_1.__exportStar(require("./lib/errors/Identifiers"), exports);
tslib_1.__exportStar(require("./lib/errors/PreconditionError"), exports);
tslib_1.__exportStar(require("./lib/errors/UserError"), exports);
tslib_1.__exportStar(require("./lib/parsers/Args"), exports);
tslib_1.__exportStar(require("./lib/parsers/Maybe"), exports);
tslib_1.__exportStar(require("./lib/parsers/Result"), exports);
tslib_1.__exportStar(require("./lib/plugins/Plugin"), exports);
tslib_1.__exportStar(require("./lib/plugins/PluginManager"), exports);
tslib_1.__exportStar(require("./lib/plugins/symbols"), exports);
tslib_1.__exportStar(require("./lib/SapphireClient"), exports);
tslib_1.__exportStar(require("./lib/structures/Argument"), exports);
tslib_1.__exportStar(require("./lib/structures/ArgumentStore"), exports);
tslib_1.__exportStar(require("./lib/structures/Command"), exports);
tslib_1.__exportStar(require("./lib/structures/CommandStore"), exports);
tslib_1.__exportStar(require("./lib/structures/Event"), exports);
tslib_1.__exportStar(require("./lib/structures/EventStore"), exports);
tslib_1.__exportStar(require("./lib/structures/ExtendedArgument"), exports);
tslib_1.__exportStar(require("./lib/structures/Precondition"), exports);
tslib_1.__exportStar(require("./lib/structures/PreconditionStore"), exports);
tslib_1.__exportStar(require("./lib/structures/StoreRegistry"), exports);
tslib_1.__exportStar(require("./lib/types/Enums"), exports);
tslib_1.__exportStar(require("./lib/types/Events"), exports);
tslib_1.__exportStar(require("./lib/utils/logger/ILogger"), exports);
tslib_1.__exportStar(require("./lib/utils/logger/Logger"), exports);
tslib_1.__exportStar(require("./lib/utils/preconditions/conditions/IPreconditionCondition"), exports);
tslib_1.__exportStar(require("./lib/utils/preconditions/conditions/PreconditionConditionAnd"), exports);
tslib_1.__exportStar(require("./lib/utils/preconditions/conditions/PreconditionConditionOr"), exports);
tslib_1.__exportStar(require("./lib/utils/preconditions/containers/PermissionsPrecondition"), exports);
tslib_1.__exportStar(require("./lib/utils/preconditions/IPreconditionContainer"), exports);
tslib_1.__exportStar(require("./lib/utils/preconditions/PreconditionContainerArray"), exports);
tslib_1.__exportStar(require("./lib/utils/preconditions/PreconditionContainerSingle"), exports);
exports.version = '2.0.0-next.d8053045.0';
Object.defineProperty(exports, "StoreRegistry", { enumerable: true, get: function () { return pieces_1.StoreRegistry; } });
(0, tslib_1.__exportStar)(require("./lib/errors/ArgumentError"), exports);
(0, tslib_1.__exportStar)(require("./lib/errors/Identifiers"), exports);
(0, tslib_1.__exportStar)(require("./lib/errors/PreconditionError"), exports);
(0, tslib_1.__exportStar)(require("./lib/errors/UserError"), exports);
(0, tslib_1.__exportStar)(require("./lib/parsers/Args"), exports);
(0, tslib_1.__exportStar)(require("./lib/parsers/Maybe"), exports);
(0, tslib_1.__exportStar)(require("./lib/parsers/Result"), exports);
(0, tslib_1.__exportStar)(require("./lib/plugins/Plugin"), exports);
(0, tslib_1.__exportStar)(require("./lib/plugins/PluginManager"), exports);
(0, tslib_1.__exportStar)(require("./lib/plugins/symbols"), exports);
exports.Resolvers = (0, tslib_1.__importStar)(require("./lib/resolvers"));
(0, tslib_1.__exportStar)(require("./lib/SapphireClient"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/Argument"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/ArgumentStore"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/Command"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/CommandStore"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/ExtendedArgument"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/Listener"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/ListenerStore"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/Precondition"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/PreconditionStore"), exports);
(0, tslib_1.__exportStar)(require("./lib/types/Enums"), exports);
(0, tslib_1.__exportStar)(require("./lib/types/Events"), exports);
(0, tslib_1.__exportStar)(require("./lib/utils/logger/ILogger"), exports);
(0, tslib_1.__exportStar)(require("./lib/utils/logger/Logger"), exports);
(0, tslib_1.__exportStar)(require("./lib/utils/preconditions/conditions/IPreconditionCondition"), exports);
(0, tslib_1.__exportStar)(require("./lib/utils/preconditions/conditions/PreconditionConditionAnd"), exports);
(0, tslib_1.__exportStar)(require("./lib/utils/preconditions/conditions/PreconditionConditionOr"), exports);
(0, tslib_1.__exportStar)(require("./lib/utils/preconditions/containers/ClientPermissionsPrecondition"), exports);
(0, tslib_1.__exportStar)(require("./lib/utils/preconditions/containers/UserPermissionsPrecondition"), exports);
(0, tslib_1.__exportStar)(require("./lib/utils/preconditions/IPreconditionContainer"), exports);
(0, tslib_1.__exportStar)(require("./lib/utils/preconditions/PreconditionContainerArray"), exports);
(0, tslib_1.__exportStar)(require("./lib/utils/preconditions/PreconditionContainerSingle"), exports);
var ClientPermissions_1 = require("./preconditions/ClientPermissions");
Object.defineProperty(exports, "ClientPermissionsCorePrecondition", { enumerable: true, get: function () { return ClientPermissions_1.CorePrecondition; } });
exports.version = '2.0.0-next.db6febd5.0';

@@ -12,4 +12,3 @@ "use strict";

constructor(options) {
var _a;
super({ ...options, identifier: (_a = options.identifier) !== null && _a !== void 0 ? _a : options.argument.name });
super({ ...options, identifier: options.identifier ?? options.argument.name });
this.argument = options.argument;

@@ -16,0 +15,0 @@ this.parameter = options.parameter;

@@ -6,43 +6,53 @@ "use strict";

(function (Identifiers) {
Identifiers["ArgumentBoolean"] = "boolean";
Identifiers["ArgumentCategoryChannel"] = "categoryChannel";
Identifiers["ArgumentChannel"] = "channel";
Identifiers["ArgumentDate"] = "date";
Identifiers["ArgumentDateTooSmall"] = "dateTooSmall";
Identifiers["ArgumentDateTooBig"] = "dateTooBig";
Identifiers["ArgumentDMChannel"] = "dmChannel";
Identifiers["ArgumentFloat"] = "float";
Identifiers["ArgsMissing"] = "argsMissing";
Identifiers["ArgsUnavailable"] = "argsUnavailable";
Identifiers["ArgumentBooleanError"] = "booleanError";
Identifiers["ArgumentChannelError"] = "channelError";
Identifiers["ArgumentDateError"] = "dateError";
Identifiers["ArgumentDateTooEarly"] = "dateTooEarly";
Identifiers["ArgumentDateTooFar"] = "dateTooFar";
Identifiers["ArgumentDMChannelError"] = "dmChannelError";
Identifiers["ArgumentFloatError"] = "floatError";
Identifiers["ArgumentFloatTooLarge"] = "floatTooLarge";
Identifiers["ArgumentFloatTooSmall"] = "floatTooSmall";
Identifiers["ArgumentFloatTooBig"] = "floatTooBig";
Identifiers["ArgumentGuildChannel"] = "guildChannel";
Identifiers["ArgumentGuildChannelMissingGuild"] = "guildChannelMissingGuild";
Identifiers["ArgumentHyperlink"] = "hyperlink";
Identifiers["ArgumentInteger"] = "integer";
Identifiers["ArgumentGuildCategoryChannelError"] = "categoryChannelError";
Identifiers["ArgumentGuildChannelError"] = "guildChannelError";
Identifiers["ArgumentGuildChannelMissingGuildError"] = "guildChannelMissingGuildError";
Identifiers["ArgumentGuildNewsChannelError"] = "guildNewsChannelError";
Identifiers["ArgumentGuildNewsThreadChannelError"] = "guildNewsChannelError";
Identifiers["ArgumentGuildPrivateThreadChannelError"] = "guildPrivateThreadChannelError";
Identifiers["ArgumentGuildPublicThreadChannelError"] = "guildPublicThreadChannelError";
Identifiers["ArgumentGuildStageVoiceChannelError"] = "guildStageVoiceChannelError";
Identifiers["ArgumentGuildTextChannelError"] = "guildTextChannelError";
Identifiers["ArgumentGuildThreadChannelError"] = "guildThreadChannelError";
Identifiers["ArgumentGuildVoiceChannelError"] = "guildVoiceChannelError";
Identifiers["ArgumentHyperlinkError"] = "hyperlinkError";
Identifiers["ArgumentIntegerError"] = "integerError";
Identifiers["ArgumentIntegerTooLarge"] = "integerTooLarge";
Identifiers["ArgumentIntegerTooSmall"] = "integerTooSmall";
Identifiers["ArgumentIntegerTooBig"] = "integerTooBig";
Identifiers["ArgumentMember"] = "member";
Identifiers["ArgumentMemberError"] = "memberError";
Identifiers["ArgumentMemberMissingGuild"] = "memberMissingGuild";
Identifiers["ArgumentMessage"] = "message";
Identifiers["ArgumentNewsChannel"] = "newsChannel";
Identifiers["ArgumentNumber"] = "number";
Identifiers["ArgumentMessageError"] = "messageError";
Identifiers["ArgumentNumberError"] = "numberError";
Identifiers["ArgumentNumberTooLarge"] = "numberTooLarge";
Identifiers["ArgumentNumberTooSmall"] = "numberTooSmall";
Identifiers["ArgumentNumberTooBig"] = "numberTooBig";
Identifiers["ArgumentRole"] = "role";
Identifiers["ArgumentRoleError"] = "roleError";
Identifiers["ArgumentRoleMissingGuild"] = "roleMissingGuild";
Identifiers["ArgumentStringTooLong"] = "stringTooLong";
Identifiers["ArgumentStringTooShort"] = "stringTooShort";
Identifiers["ArgumentStringTooLong"] = "stringTooLong";
Identifiers["ArgumentTextChannel"] = "textChannel";
Identifiers["ArgumentUser"] = "user";
Identifiers["ArgumentVoiceChannel"] = "voiceChannel";
Identifiers["ArgsUnavailable"] = "argsUnavailable";
Identifiers["ArgsMissing"] = "argsMissing";
Identifiers["ArgumentUserError"] = "userError";
Identifiers["CommandDisabled"] = "commandDisabled";
Identifiers["PreconditionCooldown"] = "preconditionCooldown";
Identifiers["PreconditionDMOnly"] = "preconditionDmOnly";
Identifiers["PreconditionGuildNewsOnly"] = "preconditionGuildNewsOnly";
Identifiers["PreconditionGuildNewsThreadOnly"] = "preconditionGuildNewsThreadOnly";
Identifiers["PreconditionGuildOnly"] = "preconditionGuildOnly";
Identifiers["PreconditionNewsOnly"] = "preconditionNewsOnly";
Identifiers["PreconditionGuildPrivateThreadOnly"] = "preconditionGuildPrivateThreadOnly";
Identifiers["PreconditionGuildPublicThreadOnly"] = "preconditionGuildPublicThreadOnly";
Identifiers["PreconditionGuildTextOnly"] = "preconditionGuildTextOnly";
Identifiers["PreconditionNSFW"] = "preconditionNsfw";
Identifiers["PreconditionPermissions"] = "preconditionPermissions";
Identifiers["PreconditionTextOnly"] = "preconditionTextOnly";
Identifiers["PreconditionClientPermissions"] = "preconditionClientPermissions";
Identifiers["PreconditionUserPermissions"] = "preconditionUserPermissions";
Identifiers["PreconditionThreadOnly"] = "preconditionThreadOnly";
})(Identifiers = exports.Identifiers || (exports.Identifiers = {}));
//# sourceMappingURL=Identifiers.js.map

@@ -11,4 +11,3 @@ "use strict";

constructor(options) {
var _a;
super({ ...options, identifier: (_a = options.identifier) !== null && _a !== void 0 ? _a : options.precondition.name });
super({ ...options, identifier: options.identifier ?? options.precondition.name });
this.precondition = options.precondition;

@@ -15,0 +14,0 @@ }

@@ -15,6 +15,5 @@ "use strict";

constructor(options) {
var _a;
super(options.message);
this.identifier = options.identifier;
this.context = (_a = options.context) !== null && _a !== void 0 ? _a : null;
this.context = options.context ?? null;
}

@@ -21,0 +20,0 @@ // eslint-disable-next-line @typescript-eslint/class-literal-property-style

@@ -51,3 +51,3 @@ "use strict";

return this.missingArguments();
if (Result_1.isOk(result))
if ((0, Result_1.isOk)(result))
return result;

@@ -58,3 +58,3 @@ return result;

const result = await this.pickResult(type, options);
if (Result_1.isOk(result))
if ((0, Result_1.isOk)(result))
return result.value;

@@ -79,3 +79,3 @@ throw result.error;

});
if (Result_1.isOk(result))
if ((0, Result_1.isOk)(result))
return result;

@@ -87,3 +87,3 @@ this.parser.restore(state);

const result = await this.restResult(type, options);
if (Result_1.isOk(result))
if ((0, Result_1.isOk)(result))
return result.value;

@@ -93,3 +93,2 @@ throw result.error;

async repeatResult(type, options = {}) {
var _a;
const argument = this.resolveArgument(type);

@@ -101,3 +100,3 @@ if (!argument)

const output = [];
for (let i = 0, times = (_a = options.times) !== null && _a !== void 0 ? _a : Infinity; i < times; i++) {
for (let i = 0, times = options.times ?? Infinity; i < times; i++) {
const result = await this.parser.singleParseAsync(async (arg) => argument.run(arg, {

@@ -113,3 +112,3 @@ args: this,

break;
if (Result_1.isErr(result)) {
if ((0, Result_1.isErr)(result)) {
if (output.length === 0)

@@ -121,7 +120,7 @@ return result;

}
return Result_1.ok(output);
return (0, Result_1.ok)(output);
}
async repeat(type, options) {
const result = await this.repeatResult(type, options);
if (Result_1.isOk(result))
if ((0, Result_1.isOk)(result))
return result.value;

@@ -138,3 +137,3 @@ throw result.error;

const result = await this.peekResult(type, options);
if (Result_1.isOk(result))
if ((0, Result_1.isOk)(result))
return result.value;

@@ -144,7 +143,7 @@ throw result.error;

nextMaybe(cb) {
return Maybe_1.maybe(typeof cb === 'function' ? this.parser.singleMap(cb) : this.parser.single());
return (0, Maybe_1.maybe)(typeof cb === 'function' ? this.parser.singleMap(cb) : this.parser.single());
}
next(cb) {
const value = cb ? this.nextMaybe(cb) : this.nextMaybe();
return Maybe_1.isSome(value) ? value.value : null;
return (0, Maybe_1.isSome)(value) ? value.value : null;
}

@@ -237,3 +236,3 @@ /**

const name = typeof type === 'string' ? type : type.name;
return Result_1.err(new UserError_1.UserError({
return (0, Result_1.err)(new UserError_1.UserError({
identifier: "argsUnavailable" /* ArgsUnavailable */,

@@ -245,3 +244,3 @@ message: `The argument "${name}" was not found.`,

missingArguments() {
return Result_1.err(new UserError_1.UserError({ identifier: "argsMissing" /* ArgsMissing */, message: 'There are no more arguments.', context: this.toJSON() }));
return (0, Result_1.err)(new UserError_1.UserError({ identifier: "argsMissing" /* ArgsMissing */, message: 'There are no more arguments.', context: this.toJSON() }));
}

@@ -269,3 +268,3 @@ /**

static ok(value) {
return Result_1.ok(value);
return (0, Result_1.ok)(value);
}

@@ -277,3 +276,3 @@ /**

static error(options) {
return Result_1.err(new ArgumentError_1.ArgumentError(options));
return (0, Result_1.err)(new ArgumentError_1.ArgumentError(options));
}

@@ -280,0 +279,0 @@ }

@@ -10,5 +10,4 @@ "use strict";

const CommandStore_1 = require("./structures/CommandStore");
const EventStore_1 = require("./structures/EventStore");
const ListenerStore_1 = require("./structures/ListenerStore");
const PreconditionStore_1 = require("./structures/PreconditionStore");
const StoreRegistry_1 = require("./structures/StoreRegistry");
require("./types/Enums");

@@ -22,5 +21,4 @@ const Events_1 = require("./types/Events");

*
* Sapphire also automatically detects the folders to scan for pieces, please read
* {@link SapphireClient.registerUserDirectories} for reference. This method is called at the start of the
* {@link SapphireClient.login} method.
* Sapphire also automatically detects the folders to scan for pieces, please read {@link StoreRegistry.registerPath}
* for reference. This method is called at the start of the {@link SapphireClient.login} method.
*

@@ -66,4 +64,3 @@ * @see {@link SapphireClientOptions} for all options available to the Sapphire Client. You can also provide all of discord.js' [ClientOptions](https://discord.js.org/#/docs/main/stable/typedef/ClientOptions)

class SapphireClient extends discord_js_1.Client {
constructor(options = {}) {
var _a, _b, _c, _d, _e, _f;
constructor(options) {
super(options);

@@ -80,7 +77,10 @@ /**

}
this.logger = (_b = (_a = options.logger) === null || _a === void 0 ? void 0 : _a.instance) !== null && _b !== void 0 ? _b : new Logger_1.Logger((_d = (_c = options.logger) === null || _c === void 0 ? void 0 : _c.level) !== null && _d !== void 0 ? _d : 30 /* Info */);
this.logger = options.logger?.instance ?? new Logger_1.Logger(options.logger?.level ?? 30 /* Info */);
pieces_1.container.logger = this.logger;
this.stores = new StoreRegistry_1.StoreRegistry();
if (options.enableLoaderTraceLoggings ?? pieces_1.container.logger.has(10 /* Trace */)) {
pieces_1.Store.logger = pieces_1.container.logger.trace.bind(pieces_1.container.logger);
}
this.stores = new pieces_1.StoreRegistry();
pieces_1.container.stores = this.stores;
this.fetchPrefix = (_e = options.fetchPrefix) !== null && _e !== void 0 ? _e : (() => { var _a; return (_a = this.options.defaultPrefix) !== null && _a !== void 0 ? _a : null; });
this.fetchPrefix = options.fetchPrefix ?? (() => this.options.defaultPrefix ?? null);
for (const plugin of SapphireClient.plugins.values("preInitialization" /* PreInitialization */)) {

@@ -90,10 +90,10 @@ plugin.hook.call(this, options);

}
this.id = (_f = options.id) !== null && _f !== void 0 ? _f : null;
this.id = options.id ?? null;
this.stores
.register(new ArgumentStore_1.ArgumentStore().registerPath(path_1.join(__dirname, '..', 'arguments'))) //
.register(new ArgumentStore_1.ArgumentStore().registerPath((0, path_1.join)(__dirname, '..', 'arguments'))) //
.register(new CommandStore_1.CommandStore())
.register(new EventStore_1.EventStore().registerPath(path_1.join(__dirname, '..', 'events')))
.register(new PreconditionStore_1.PreconditionStore().registerPath(path_1.join(__dirname, '..', 'preconditions')));
if (options.loadDefaultErrorEvents !== false)
this.stores.get('events').registerPath(path_1.join(__dirname, '..', 'errorEvents'));
.register(new ListenerStore_1.ListenerStore().registerPath((0, path_1.join)(__dirname, '..', 'listeners')))
.register(new PreconditionStore_1.PreconditionStore().registerPath((0, path_1.join)(__dirname, '..', 'preconditions')));
if (options.loadDefaultErrorListeners !== false)
this.stores.get('listeners').registerPath((0, path_1.join)(__dirname, '..', 'errorListeners'));
for (const plugin of SapphireClient.plugins.values("postInitialization" /* PostInitialization */)) {

@@ -113,3 +113,3 @@ plugin.hook.call(this, options);

if (this.options.baseUserDirectory !== null) {
this.stores.registerUserDirectories(this.options.baseUserDirectory);
this.stores.registerPath(this.options.baseUserDirectory);
}

@@ -116,0 +116,0 @@ // Call pre-login plugins:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CommandPreConditions = exports.Command = void 0;
exports.CommandPreConditions = exports.CommandOptionsRunTypeEnum = exports.Command = void 0;
const tslib_1 = require("tslib");
const pieces_1 = require("@sapphire/pieces");
const utilities_1 = require("@sapphire/utilities");
const Lexure = tslib_1.__importStar(require("lexure"));
const discord_js_1 = require("discord.js");
const Lexure = (0, tslib_1.__importStar)(require("lexure"));
const Args_1 = require("../parsers/Args");
require("../types/Enums");
const PreconditionContainerArray_1 = require("../utils/preconditions/PreconditionContainerArray");

@@ -17,5 +19,4 @@ const FlagUnorderedStrategy_1 = require("../utils/strategies/FlagUnorderedStrategy");

*/
constructor(context, { name, ...options } = {}) {
var _a, _b, _c;
super(context, { ...options, name: (name !== null && name !== void 0 ? name : context.name).toLowerCase() });
constructor(context, options = {}) {
super(context, { ...options, name: (options.name ?? context.name).toLowerCase() });
/**

@@ -27,6 +28,7 @@ * The lexer to be used for command parsing

this.lexer = new Lexure.Lexer();
this.description = (_a = options.description) !== null && _a !== void 0 ? _a : '';
this.detailedDescription = (_b = options.detailedDescription) !== null && _b !== void 0 ? _b : '';
this.strategy = new FlagUnorderedStrategy_1.FlagUnorderedStrategy(options.strategyOptions);
this.lexer.setQuotes((_c = options.quotes) !== null && _c !== void 0 ? _c : [
this.description = options.description ?? '';
this.detailedDescription = options.detailedDescription ?? '';
this.strategy = new FlagUnorderedStrategy_1.FlagUnorderedStrategy(options);
this.fullCategory = options.fullCategory ?? this.location.directories;
this.lexer.setQuotes(options.quotes ?? [
['"', '"'],

@@ -45,3 +47,4 @@ ['β€œ', '”'],

}
this.preconditions = new PreconditionContainerArray_1.PreconditionContainerArray(this.resolveConstructorPreConditions(options));
this.preconditions = new PreconditionContainerArray_1.PreconditionContainerArray(options.preconditions);
this.parseConstructorPreConditions(options);
}

@@ -60,2 +63,35 @@ /**

/**
* The main category for the command, if any.
*
* This getter retrieves the first value of {@link Command.fullCategory}, if it has at least one item, otherwise it
* returns `null`.
*
* @note You can set {@link CommandOptions.fullCategory} to override the built-in category resolution.
*/
get category() {
return this.fullCategory.length > 0 ? this.fullCategory[0] : null;
}
/**
* The sub-category for the command, if any.
*
* This getter retrieves the second value of {@link Command.fullCategory}, if it has at least two items, otherwise
* it returns `null`.
*
* @note You can set {@link CommandOptions.fullCategory} to override the built-in category resolution.
*/
get subCategory() {
return this.fullCategory.length > 1 ? this.fullCategory[1] : null;
}
/**
* The parent category for the command.
*
* This getter retrieves the last value of {@link Command.fullCategory}, if it has at least one item, otherwise it
* returns `null`.
*
* @note You can set {@link CommandOptions.fullCategory} to override the built-in category resolution.
*/
get parentCategory() {
return this.fullCategory.length > 1 ? this.fullCategory[this.fullCategory.length - 1] : null;
}
/**
* Defines the JSON.stringify behavior of the command.

@@ -68,32 +104,96 @@ */

detailedDescription: this.detailedDescription,
strategy: this.strategy
category: this.category
};
}
resolveConstructorPreConditions(options) {
var _a, _b, _c;
const preconditions = (_b = (_a = options.preconditions) === null || _a === void 0 ? void 0 : _a.slice()) !== null && _b !== void 0 ? _b : [];
/**
* Parses the command's options and processes them, calling {@link Command#parseConstructorPreConditionsRunIn},
* {@link Command#parseConstructorPreConditionsNsfw},
* {@link Command#parseConstructorPreConditionsRequiredClientPermissions}, and
* {@link Command#parseConstructorPreConditionsCooldown}.
* @since 2.0.0
* @param options The command options given from the constructor.
*/
parseConstructorPreConditions(options) {
this.parseConstructorPreConditionsRunIn(options);
this.parseConstructorPreConditionsNsfw(options);
this.parseConstructorPreConditionsRequiredClientPermissions(options);
this.parseConstructorPreConditionsRequiredUserPermissions(options);
this.parseConstructorPreConditionsCooldown(options);
}
/**
* Appends the `NSFW` precondition if {@link CommandOptions.nsfw} is set to true.
* @param options The command options given from the constructor.
*/
parseConstructorPreConditionsNsfw(options) {
if (options.nsfw)
preconditions.push("NSFW" /* NotSafeForWork */);
this.preconditions.append("NSFW" /* NotSafeForWork */);
}
/**
* Appends the `DMOnly`, `GuildOnly`, `NewsOnly`, and `TextOnly` preconditions based on the values passed in
* {@link CommandOptions.runIn}, optimizing in specific cases (`NewsOnly` + `TextOnly` = `GuildOnly`; `DMOnly` +
* `GuildOnly` = `null`), defaulting to `null`, which doesn't add a precondition.
* @param options The command options given from the constructor.
*/
parseConstructorPreConditionsRunIn(options) {
const runIn = this.resolveConstructorPreConditionsRunType(options.runIn);
if (runIn !== null)
preconditions.push(runIn);
const cooldownBucket = (_c = options.cooldownBucket) !== null && _c !== void 0 ? _c : 1;
if (cooldownBucket && options.cooldownDuration) {
preconditions.push({ name: "Cooldown" /* Cooldown */, context: { bucket: cooldownBucket, cooldown: options.cooldownDuration } });
this.preconditions.append(runIn);
}
/**
* Appends the `ClientPermissions` precondition when {@link CommandOptions.requiredClientPermissions} resolves to a
* non-zero bitfield.
* @param options The command options given from the constructor.
*/
parseConstructorPreConditionsRequiredClientPermissions(options) {
const permissions = new discord_js_1.Permissions(options.requiredClientPermissions);
if (permissions.bitfield !== 0n) {
this.preconditions.append({ name: "ClientPermissions" /* ClientPermissions */, context: { permissions } });
}
return preconditions;
}
/**
* Appends the `UserPermissions` precondition when {@link CommandOptions.requiredUserPermissions} resolves to a
* non-zero bitfield.
* @param options The command options given from the constructor.
*/
parseConstructorPreConditionsRequiredUserPermissions(options) {
const permissions = new discord_js_1.Permissions(options.requiredUserPermissions);
if (permissions.bitfield !== 0n) {
this.preconditions.append({ name: "UserPermissions" /* UserPermissions */, context: { permissions } });
}
}
/**
* Appends the `Cooldown` precondition when {@link CommandOptions.cooldownLimit} and
* {@link CommandOptions.cooldownDelay} are both non-zero.
* @param options The command options given from the constructor.
*/
parseConstructorPreConditionsCooldown(options) {
const limit = options.cooldownLimit ?? 1;
const delay = options.cooldownDelay ?? 0;
const filteredUsers = options.cooldownFilteredUsers;
if (limit && delay) {
this.preconditions.append({
name: "Cooldown" /* Cooldown */,
context: { scope: options.cooldownScope ?? 3 /* User */, limit, delay, filteredUsers }
});
}
}
resolveConstructorPreConditionsRunType(runIn) {
if (utilities_1.isNullish(runIn))
if ((0, utilities_1.isNullish)(runIn))
return null;
if (typeof runIn === 'string') {
switch (runIn) {
case 'dm':
return ["DMOnly" /* DirectMessageOnly */];
case 'text':
return ["TextOnly" /* TextOnly */];
case 'news':
return ["NewsOnly" /* NewsOnly */];
case 'guild':
return ["GuildOnly" /* GuildOnly */];
case 'DM':
return "DMOnly" /* DirectMessageOnly */;
case 'GUILD_TEXT':
return "GuildTextOnly" /* GuildTextOnly */;
case 'GUILD_NEWS':
return "GuildNewsOnly" /* GuildNewsOnly */;
case 'GUILD_NEWS_THREAD':
return "GuildNewsThreadOnly" /* GuildNewsThreadOnly */;
case 'GUILD_PUBLIC_THREAD':
return "GuildPublicThreadOnly" /* GuildPublicThreadOnly */;
case 'GUILD_PRIVATE_THREAD':
return "GuildPrivateThreadOnly" /* GuildPrivateThreadOnly */;
case 'GUILD_ANY':
return "GuildOnly" /* GuildOnly */;
default:

@@ -107,19 +207,47 @@ return null;

}
const dm = runIn.includes('dm');
const text = runIn.includes('text');
const news = runIn.includes('news');
const guild = text && news;
if (runIn.length === 1) {
return this.resolveConstructorPreConditionsRunType(runIn[0]);
}
const keys = new Set(runIn);
const dm = keys.has('DM');
const guildText = keys.has('GUILD_TEXT');
const guildNews = keys.has('GUILD_NEWS');
const guild = guildText && guildNews;
// If runs everywhere, optimise to null:
if (dm && guild)
return null;
const array = [];
const guildPublicThread = keys.has('GUILD_PUBLIC_THREAD');
const guildPrivateThread = keys.has('GUILD_PRIVATE_THREAD');
const guildNewsThread = keys.has('GUILD_NEWS_THREAD');
const guildThreads = guildPublicThread && guildPrivateThread && guildNewsThread;
// If runs in any thread, optimise to thread-only:
if (guildThreads && keys.size === 3) {
return "GuildThreadOnly" /* GuildThreadOnly */;
}
const preconditions = new PreconditionContainerArray_1.PreconditionContainerArray();
if (dm)
array.push("DMOnly" /* DirectMessageOnly */);
if (guild)
array.push("GuildOnly" /* GuildOnly */);
else if (text)
array.push("TextOnly" /* TextOnly */);
else if (news)
array.push("NewsOnly" /* NewsOnly */);
return array;
preconditions.append("DMOnly" /* DirectMessageOnly */);
if (guild) {
preconditions.append("GuildOnly" /* GuildOnly */);
}
else {
// GuildText includes PublicThread and PrivateThread
if (guildText) {
preconditions.append("GuildTextOnly" /* GuildTextOnly */);
}
else {
if (guildPublicThread)
preconditions.append("GuildPublicThreadOnly" /* GuildPublicThreadOnly */);
if (guildPrivateThread)
preconditions.append("GuildPrivateThreadOnly" /* GuildPrivateThreadOnly */);
}
// GuildNews includes NewsThread
if (guildNews) {
preconditions.append("GuildNewsOnly" /* GuildNewsOnly */);
}
else if (guildNewsThread) {
preconditions.append("GuildNewsThreadOnly" /* GuildNewsThreadOnly */);
}
}
return preconditions;
}

@@ -129,2 +257,16 @@ }

/**
* The allowed values for {@link CommandOptions.runIn} as an enum.
* @since 2.0.0
*/
var CommandOptionsRunTypeEnum;
(function (CommandOptionsRunTypeEnum) {
CommandOptionsRunTypeEnum["Dm"] = "DM";
CommandOptionsRunTypeEnum["GuildText"] = "GUILD_TEXT";
CommandOptionsRunTypeEnum["GuildNews"] = "GUILD_NEWS";
CommandOptionsRunTypeEnum["GuildNewsThread"] = "GUILD_NEWS_THREAD";
CommandOptionsRunTypeEnum["GuildPublicThread"] = "GUILD_PUBLIC_THREAD";
CommandOptionsRunTypeEnum["GuildPrivateThread"] = "GUILD_PRIVATE_THREAD";
CommandOptionsRunTypeEnum["GuildAny"] = "GUILD_ANY";
})(CommandOptionsRunTypeEnum = exports.CommandOptionsRunTypeEnum || (exports.CommandOptionsRunTypeEnum = {}));
/**
* The available command pre-conditions.

@@ -136,8 +278,14 @@ * @since 2.0.0

CommandPreConditions["Cooldown"] = "Cooldown";
CommandPreConditions["NotSafeForWork"] = "NSFW";
CommandPreConditions["DirectMessageOnly"] = "DMOnly";
CommandPreConditions["TextOnly"] = "TextOnly";
CommandPreConditions["NewsOnly"] = "NewsOnly";
CommandPreConditions["GuildNewsOnly"] = "GuildNewsOnly";
CommandPreConditions["GuildNewsThreadOnly"] = "GuildNewsThreadOnly";
CommandPreConditions["GuildOnly"] = "GuildOnly";
CommandPreConditions["GuildPrivateThreadOnly"] = "GuildPrivateThreadOnly";
CommandPreConditions["GuildPublicThreadOnly"] = "GuildPublicThreadOnly";
CommandPreConditions["GuildTextOnly"] = "GuildTextOnly";
CommandPreConditions["GuildThreadOnly"] = "GuildThreadOnly";
CommandPreConditions["NotSafeForWork"] = "NSFW";
CommandPreConditions["ClientPermissions"] = "ClientPermissions";
CommandPreConditions["UserPermissions"] = "UserPermissions";
})(CommandPreConditions = exports.CommandPreConditions || (exports.CommandPreConditions = {}));
//# sourceMappingURL=Command.js.map

@@ -14,4 +14,12 @@ "use strict";

}
/**
* Get all the command categories.
*/
get categories() {
const categories = new Set(this.map((command) => command.category));
categories.delete(null);
return [...categories];
}
}
exports.CommandStore = CommandStore;
//# sourceMappingURL=CommandStore.js.map

@@ -69,3 +69,3 @@ "use strict";

// the error as is; it'll provide contextual information from the base argument.
return Result_1.isOk(result) ? this.handle(result.value, { ...context, parameter }) : result;
return (0, Result_1.isOk)(result) ? this.handle(result.value, { ...context, parameter }) : result;
}

@@ -72,0 +72,0 @@ }

@@ -9,8 +9,7 @@ "use strict";

constructor(context, options = {}) {
var _a;
super(context, options);
this.position = (_a = options.position) !== null && _a !== void 0 ? _a : null;
this.position = options.position ?? null;
}
ok() {
return Result_1.ok();
return (0, Result_1.ok)();
}

@@ -22,3 +21,3 @@ /**

error(options = {}) {
return Result_1.err(new PreconditionError_1.PreconditionError({ precondition: this, ...options }));
return (0, Result_1.err)(new PreconditionError_1.PreconditionError({ precondition: this, ...options }));
}

@@ -25,0 +24,0 @@ }

@@ -18,3 +18,3 @@ "use strict";

}
return Result_1.ok();
return (0, Result_1.ok)();
}

@@ -21,0 +21,0 @@ set(key, value) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BucketType = exports.PluginHook = exports.CooldownLevel = void 0;
exports.BucketScope = exports.PluginHook = exports.CooldownLevel = void 0;
var CooldownLevel;

@@ -19,23 +19,23 @@ (function (CooldownLevel) {

/**
* The level the cooldown applies to
* The scope the cooldown applies to.
*/
var BucketType;
(function (BucketType) {
var BucketScope;
(function (BucketScope) {
/**
* Per channel cooldowns
* Per channel cooldowns.
*/
BucketType[BucketType["Channel"] = 0] = "Channel";
BucketScope[BucketScope["Channel"] = 0] = "Channel";
/**
* Global cooldowns
* Global cooldowns.
*/
BucketType[BucketType["Global"] = 1] = "Global";
BucketScope[BucketScope["Global"] = 1] = "Global";
/**
* Per guild cooldowns
* Per guild cooldowns.
*/
BucketType[BucketType["Guild"] = 2] = "Guild";
BucketScope[BucketScope["Guild"] = 2] = "Guild";
/**
* Per user cooldowns
* Per user cooldowns.
*/
BucketType[BucketType["User"] = 3] = "User";
})(BucketType = exports.BucketType || (exports.BucketType = {}));
BucketScope[BucketScope["User"] = 3] = "User";
})(BucketScope = exports.BucketScope || (exports.BucketScope = {}));
//# sourceMappingURL=Enums.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Events = void 0;
var Events;
(function (Events) {
const discord_js_1 = require("discord.js");
exports.Events = {
// #region Discord.js base events
Events["ChannelCreate"] = "channelCreate";
Events["ChannelDelete"] = "channelDelete";
Events["ChannelPinsUpdate"] = "channelPinsUpdate";
Events["ChannelUpdate"] = "channelUpdate";
Events["Debug"] = "debug";
Events["Warn"] = "warn";
Events["Disconnect"] = "disconnect";
Events["EmojiCreate"] = "emojiCreate";
Events["EmojiDelete"] = "emojiDelete";
Events["EmojiUpdate"] = "emojiUpdate";
Events["Error"] = "error";
Events["GuildBanAdd"] = "guildBanAdd";
Events["GuildBanRemove"] = "guildBanRemove";
Events["GuildCreate"] = "guildCreate";
Events["GuildDelete"] = "guildDelete";
Events["GuildUnavailable"] = "guildUnavailable";
Events["GuildIntegrationsUpdate"] = "guildIntegrationsUpdate";
Events["GuildMemberAdd"] = "guildMemberAdd";
Events["GuildMemberAvailable"] = "guildMemberAvailable";
Events["GuildMemberRemove"] = "guildMemberRemove";
Events["GuildMembersChunk"] = "guildMembersChunk";
Events["GuildMemberSpeaking"] = "guildMemberSpeaking";
Events["GuildMemberUpdate"] = "guildMemberUpdate";
Events["GuildUpdate"] = "guildUpdate";
Events["InviteCreate"] = "inviteCreate";
Events["InviteDelete"] = "inviteDelete";
Events["Message"] = "message";
Events["MessageDelete"] = "messageDelete";
Events["MessageReactionRemoveAll"] = "messageReactionRemoveAll";
Events["MessageReactionRemoveEmoji"] = "messageReactionRemoveEmoji";
Events["MessageDeleteBulk"] = "messageDeleteBulk";
Events["MessageReactionAdd"] = "messageReactionAdd";
Events["MessageReactionRemove"] = "messageReactionRemove";
Events["MessageUpdate"] = "messageUpdate";
Events["PresenceUpdate"] = "presenceUpdate";
Events["RateLimit"] = "rateLimit";
Events["Ready"] = "ready";
Events["Invalidated"] = "invalidated";
Events["RoleCreate"] = "roleCreate";
Events["RoleDelete"] = "roleDelete";
Events["RoleUpdate"] = "roleUpdate";
Events["TypingsStart"] = "typingStart";
Events["UserUpdate"] = "userUpdate";
Events["VoiceStateUpdate"] = "voiceStateUpdate";
Events["WebhookUpdate"] = "webhookUpdate";
Events["ShardDisconnect"] = "shardDisconnect";
Events["ShardError"] = "shardError";
Events["ShardReady"] = "shardReady";
Events["ShardReconnecting"] = "shardReconnecting";
Events["ShardResume"] = "shardResume";
ChannelCreate: discord_js_1.Constants.Events.CHANNEL_CREATE,
ChannelDelete: discord_js_1.Constants.Events.CHANNEL_DELETE,
ChannelPinsUpdate: discord_js_1.Constants.Events.CHANNEL_PINS_UPDATE,
ChannelUpdate: discord_js_1.Constants.Events.CHANNEL_UPDATE,
ClientReady: discord_js_1.Constants.Events.CLIENT_READY,
Debug: discord_js_1.Constants.Events.DEBUG,
Error: discord_js_1.Constants.Events.ERROR,
GuildBanAdd: discord_js_1.Constants.Events.GUILD_BAN_ADD,
GuildBanRemove: discord_js_1.Constants.Events.GUILD_BAN_REMOVE,
GuildCreate: discord_js_1.Constants.Events.GUILD_CREATE,
GuildDelete: discord_js_1.Constants.Events.GUILD_DELETE,
GuildEmojiCreate: discord_js_1.Constants.Events.GUILD_EMOJI_CREATE,
GuildEmojiDelete: discord_js_1.Constants.Events.GUILD_EMOJI_DELETE,
GuildEmojiUpdate: discord_js_1.Constants.Events.GUILD_EMOJI_UPDATE,
GuildIntegrationsUpdate: discord_js_1.Constants.Events.GUILD_INTEGRATIONS_UPDATE,
GuildMemberAdd: discord_js_1.Constants.Events.GUILD_MEMBER_ADD,
GuildMemberAvailable: discord_js_1.Constants.Events.GUILD_MEMBER_AVAILABLE,
GuildMemberRemove: discord_js_1.Constants.Events.GUILD_MEMBER_REMOVE,
GuildMemberUpdate: discord_js_1.Constants.Events.GUILD_MEMBER_UPDATE,
GuildMembersChunk: discord_js_1.Constants.Events.GUILD_MEMBERS_CHUNK,
GuildRoleCreate: discord_js_1.Constants.Events.GUILD_ROLE_CREATE,
GuildRoleDelete: discord_js_1.Constants.Events.GUILD_ROLE_DELETE,
GuildRoleUpdate: discord_js_1.Constants.Events.GUILD_ROLE_UPDATE,
GuildUnavailable: discord_js_1.Constants.Events.GUILD_UNAVAILABLE,
GuildUpdate: discord_js_1.Constants.Events.GUILD_UPDATE,
Invalidated: discord_js_1.Constants.Events.INVALIDATED,
InviteCreate: discord_js_1.Constants.Events.INVITE_CREATE,
InviteDelete: discord_js_1.Constants.Events.INVITE_DELETE,
MessageBulkDelete: discord_js_1.Constants.Events.MESSAGE_BULK_DELETE,
MessageCreate: discord_js_1.Constants.Events.MESSAGE_CREATE,
MessageDelete: discord_js_1.Constants.Events.MESSAGE_DELETE,
MessageReactionAdd: discord_js_1.Constants.Events.MESSAGE_REACTION_ADD,
MessageReactionRemoveAll: discord_js_1.Constants.Events.MESSAGE_REACTION_REMOVE_ALL,
MessageReactionRemove: discord_js_1.Constants.Events.MESSAGE_REACTION_REMOVE,
MessageUpdate: discord_js_1.Constants.Events.MESSAGE_UPDATE,
PresenceUpdate: discord_js_1.Constants.Events.PRESENCE_UPDATE,
RateLimit: discord_js_1.Constants.Events.RATE_LIMIT,
Raw: discord_js_1.Constants.Events.RAW,
ShardDisconnect: discord_js_1.Constants.Events.SHARD_DISCONNECT,
ShardError: discord_js_1.Constants.Events.SHARD_ERROR,
ShardReady: discord_js_1.Constants.Events.SHARD_READY,
ShardReconnecting: discord_js_1.Constants.Events.SHARD_RECONNECTING,
ShardResume: discord_js_1.Constants.Events.SHARD_RESUME,
TypingStart: discord_js_1.Constants.Events.TYPING_START,
UserUpdate: discord_js_1.Constants.Events.USER_UPDATE,
VoiceStateUpdate: discord_js_1.Constants.Events.VOICE_STATE_UPDATE,
Warn: discord_js_1.Constants.Events.WARN,
WebhooksUpdate: discord_js_1.Constants.Events.WEBHOOKS_UPDATE,
// #endregion Discord.js base events
// #region Sapphire load cycle events
Events["PieceUnload"] = "pieceUnload";
Events["PiecePostLoad"] = "piecePostLoad";
Events["MentionPrefixOnly"] = "mentionPrefixOnly";
Events["EventError"] = "eventError";
Events["PreMessageParsed"] = "preMessageParsed";
Events["PrefixedMessage"] = "prefixedMessage";
Events["UnknownCommandName"] = "unknownCommandName";
Events["UnknownCommand"] = "unknownCommand";
Events["PreCommandRun"] = "preCommandRun";
Events["CommandDenied"] = "commandDenied";
Events["CommandAccepted"] = "commandAccepted";
Events["CommandRun"] = "commandRun";
Events["CommandSuccess"] = "commandSuccess";
Events["CommandFinish"] = "commandFinish";
Events["CommandError"] = "commandError";
Events["PluginLoaded"] = "pluginLoaded";
Events["NonPrefixedMessage"] = "nonPrefixedMessage";
CommandAccepted: 'commandAccepted',
CommandDenied: 'commandDenied',
CommandError: 'commandError',
CommandFinish: 'commandFinish',
CommandRun: 'commandRun',
CommandSuccess: 'commandSuccess',
ListenerError: 'listenerError',
MentionPrefixOnly: 'mentionPrefixOnly',
NonPrefixedMessage: 'nonPrefixedMessage',
PiecePostLoad: 'piecePostLoad',
PieceUnload: 'pieceUnload',
PluginLoaded: 'pluginLoaded',
PreCommandRun: 'preCommandRun',
PrefixedMessage: 'prefixedMessage',
PreMessageParsed: 'preMessageParsed',
UnknownCommand: 'unknownCommand',
UnknownCommandName: 'unknownCommandName'
// #endregion Sapphire load cycle events
})(Events = exports.Events || (exports.Events = {}));
};
//# sourceMappingURL=Events.js.map

@@ -9,2 +9,5 @@ "use strict";

}
has(level) {
return level >= this.level;
}
trace(...values) {

@@ -29,3 +32,3 @@ this.write(10 /* Trace */, ...values);

write(level, ...values) {
if (level < this.level)
if (!this.has(level))
return;

@@ -32,0 +35,0 @@ const method = Logger.levels.get(level);

@@ -13,15 +13,14 @@ "use strict";

const result = await child.run(message, command, context);
if (Result_1.isErr(result))
if ((0, Result_1.isErr)(result))
return result;
}
return Result_1.ok();
return (0, Result_1.ok)();
},
async parallel(message, command, entries, context) {
var _a;
const results = await Promise.all(entries.map((entry) => entry.run(message, command, context)));
// This is simplified compared to PreconditionContainerAny because we're looking for the first error.
// However, the base implementation short-circuits with the first Ok.
return (_a = results.find(Result_1.isErr)) !== null && _a !== void 0 ? _a : Result_1.ok();
return results.find(Result_1.isErr) ?? (0, Result_1.ok)();
}
};
//# sourceMappingURL=PreconditionConditionAnd.js.map

@@ -14,7 +14,7 @@ "use strict";

const result = await child.run(message, command, context);
if (Result_1.isOk(result))
if ((0, Result_1.isOk)(result))
return result;
error = result;
}
return error !== null && error !== void 0 ? error : Result_1.ok();
return error ?? (0, Result_1.ok)();
},

@@ -25,9 +25,9 @@ async parallel(message, command, entries, context) {

for (const result of results) {
if (Result_1.isOk(result))
if ((0, Result_1.isOk)(result))
return result;
error = result;
}
return error !== null && error !== void 0 ? error : Result_1.ok();
return error ?? (0, Result_1.ok)();
}
};
//# sourceMappingURL=PreconditionConditionOr.js.map

@@ -67,8 +67,7 @@ "use strict";

constructor(data = [], parent = null) {
var _a;
this.entries = [];
this.runCondition = (parent === null || parent === void 0 ? void 0 : parent.runCondition) === PreconditionRunCondition.And ? PreconditionRunCondition.Or : PreconditionRunCondition.And;
this.runCondition = parent?.runCondition === PreconditionRunCondition.And ? PreconditionRunCondition.Or : PreconditionRunCondition.And;
if (Array.isArray(data)) {
const casted = data;
this.mode = (_a = parent === null || parent === void 0 ? void 0 : parent.mode) !== null && _a !== void 0 ? _a : 0 /* Sequential */;
this.mode = parent?.mode ?? 0 /* Sequential */;
this.parse(casted);

@@ -91,2 +90,6 @@ }

}
append(entry) {
this.entries.push(entry instanceof PreconditionContainerArray ? entry : new PreconditionContainerSingle_1.PreconditionContainerSingle(entry));
return this;
}
/**

@@ -93,0 +96,0 @@ * Runs the container.

@@ -16,3 +16,3 @@ "use strict";

else {
this.context = data.context;
this.context = Reflect.get(data, 'context') ?? {};
this.name = data.name;

@@ -19,0 +19,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FlagUnorderedStrategy = void 0;
const never = () => null;
const always = () => true;
class FlagUnorderedStrategy {
constructor({ flags = [], options = [], prefixes = ['--', '-', 'β€”'], separators = ['=', ':'] } = {}) {
this.flags = flags;
this.options = options;
constructor({ flags, options, prefixes = ['--', '-', 'β€”'], separators = ['=', ':'] } = {}) {
this.flags = flags || [];
this.options = options || [];
this.prefixes = prefixes;
this.separators = separators;
if (this.flags === true)
this.allowedFlag = always;
else if (this.flags.length === 0)
this.matchFlag = never;
if (this.options === true) {
this.allowedOption = always;
}
else if (this.options.length === 0) {
this.matchOption = never;
this.matchCompactOption = never;
}
}

@@ -20,3 +33,3 @@ matchFlag(s) {

// The flag must be an allowed one.
if (this.flags.includes(s))
if (this.allowedFlag(s))
return s;

@@ -35,3 +48,3 @@ // If it did not match a flag, return null.

s = s.slice(0, -separator.length);
if (this.options.includes(s))
if (this.allowedOption(s))
return s;

@@ -52,3 +65,3 @@ return null;

const k = s.slice(0, i);
if (!this.options.includes(k))
if (!this.allowedOption(k))
return null;

@@ -58,4 +71,10 @@ const v = s.slice(i + sep.length);

}
allowedFlag(s) {
return this.flags.includes(s);
}
allowedOption(s) {
return this.options.includes(s);
}
}
exports.FlagUnorderedStrategy = FlagUnorderedStrategy;
//# sourceMappingURL=FlagUnorderedStrategy.js.map

@@ -20,7 +20,9 @@ "use strict";

return this.ok();
const bucket = this.getBucket(command, context);
const remaining = bucket.take(this.getID(message, context));
return remaining === 0
? this.ok()
: this.error({
// If the user has provided any filtered users and the message author is in that array, return ok:
if (context.filteredUsers?.includes(message.author.id))
return this.ok();
const ratelimit = this.getManager(command, context).acquire(this.getId(message, context));
if (ratelimit.limited) {
const remaining = ratelimit.remainingTime;
return this.error({
identifier: "preconditionCooldown" /* PreconditionCooldown */,

@@ -30,5 +32,8 @@ message: `You have just used this command. Try again in ${Math.ceil(remaining / 1000)} second${remaining > 1000 ? 's' : ''}.`,

});
}
ratelimit.consume();
return this.ok();
}
getID(message, context) {
switch (context.bucketType) {
getId(message, context) {
switch (context.scope) {
case 1 /* Global */:

@@ -39,3 +44,3 @@ return 'global';

case 2 /* Guild */:
return message.guild.id;
return message.guild?.id ?? message.channel.id;
default:

@@ -45,14 +50,9 @@ return message.author.id;

}
getBucket(command, context) {
var _a;
let bucket = this.buckets.get(command);
if (!bucket) {
bucket = new ratelimits_1.Bucket();
if (((_a = context.limit) !== null && _a !== void 0 ? _a : 1) <= 1)
bucket.setDelay(context.delay);
else
bucket.setLimit({ timespan: context.delay, maximum: context.limit });
this.buckets.set(command, bucket);
getManager(command, context) {
let manager = this.buckets.get(command);
if (!manager) {
manager = new ratelimits_1.RateLimitManager(context.delay, context.limit);
this.buckets.set(command, manager);
}
return bucket;
return manager;
}

@@ -59,0 +59,0 @@ }

{
"name": "@sapphire/framework",
"version": "2.0.0-next.d8053045.0",
"version": "2.0.0-next.db6febd5.0",
"description": "Discord bot framework built on top of @sapphire/lib for advanced and amazing bots.",

@@ -17,9 +17,4 @@ "main": "dist/index.js",

"update": "yarn upgrade-interactive --latest",
"build": "run-s build:tsc",
"build:cleanup": "node scripts/clean-dist.mjs",
"build:tsc": "tsc -b src",
"build:rollup-bundle": "rollup -c scripts/rollup.bundle.ts",
"build:rollup-types": "rollup -c scripts/rollup.types.ts",
"build:clean-extraneous-types": "node scripts/clean-extraneous-types.mjs",
"clean": "yarn build:cleanup",
"clean": "node scripts/clean-dist.mjs",
"build": "tsc -b src && rollup -c scripts/rollup.bundle.ts",
"watch": "tsc -b src -w",

@@ -29,40 +24,40 @@ "sversion": "standard-version",

"cz": "git-cz",
"prepublishOnly": "run-s build:*",
"prepublishOnly": "rollup-type-bundler -e url events",
"prepare": "husky install .github/husky"
},
"dependencies": {
"@sapphire/discord-utilities": "^2.1.4",
"@sapphire/discord.js-utilities": "^1.5.10",
"@sapphire/pieces": "~2.0.0",
"@sapphire/ratelimits": "^1.2.3",
"@sapphire/utilities": "^1.6.0",
"@sapphire/discord-utilities": "^2.1.5",
"@sapphire/discord.js-utilities": "next",
"@sapphire/pieces": "^3.0.0",
"@sapphire/ratelimits": "^2.0.1",
"@sapphire/utilities": "^2.0.1",
"lexure": "^0.17.0",
"tslib": "^2.3.0"
"tslib": "^2.3.1"
},
"devDependencies": {
"@commitlint/cli": "^12.1.4",
"@commitlint/config-conventional": "^12.1.4",
"@sapphire/eslint-config": "^3.2.0",
"@sapphire/prettier-config": "^1.1.4",
"@sapphire/ts-config": "^2.3.0",
"@types/jest": "^26.0.23",
"@types/node": "^15.12.4",
"@types/ws": "^7.4.5",
"@commitlint/cli": "^13.1.0",
"@commitlint/config-conventional": "^13.1.0",
"@favware/npm-deprecate": "^1.0.2",
"@favware/rollup-type-bundler": "^1.0.3",
"@sapphire/eslint-config": "^3.2.3",
"@sapphire/prettier-config": "^1.1.6",
"@sapphire/ts-config": "^3.0.0",
"@types/jest": "^27.0.1",
"@types/node": "^16.7.10",
"@types/ws": "^7.4.7",
"cz-conventional-changelog": "^3.3.0",
"discord.js": "^12.5.3",
"husky": "^6.0.0",
"jest": "^27.0.4",
"jest-circus": "^27.0.4",
"lint-staged": "^11.0.0",
"npm-run-all": "^4.1.5",
"discord.js": "^13.1.0",
"husky": "^7.0.2",
"jest": "^27.1.0",
"jest-circus": "^27.1.0",
"lint-staged": "^11.1.2",
"pretty-quick": "^3.1.1",
"rollup": "^2.52.3",
"rollup-plugin-dts": "^3.0.2",
"rollup": "^2.56.3",
"rollup-plugin-version-injector": "^1.3.3",
"standard-version": "^9.3.0",
"ts-jest": "^27.0.3",
"ts-node": "^10.0.0",
"typedoc": "^0.21.0",
"standard-version": "^9.3.1",
"ts-jest": "^27.0.5",
"ts-node": "^10.2.1",
"typedoc": "^0.21.9",
"typedoc-plugin-nojekyll": "^1.0.1",
"typescript": "^4.3.4"
"typescript": "^4.4.2"
},

@@ -111,3 +106,3 @@ "repository": {

"resolutions": {
"acorn": "^8.4.0",
"acorn": "^8.4.1",
"minimist": "^1.2.5",

@@ -119,3 +114,3 @@ "kind-of": "^6.0.3",

"lodash": "^4.17.21",
"marked": "^2.1.1",
"marked": "^2.1.3",
"merge": "^2.1.1",

@@ -122,0 +117,0 @@ "trim": "^1.0.1",

@@ -27,3 +27,3 @@ <div align="center">

- Written in TypeScript
- Command Handler, Arguments, Pre-conditions and Events Store
- Command Handler, Arguments, Pre-conditions and Listeners Store
- Completely Modular and Extendable

@@ -73,21 +73,22 @@ - Advanced Plugins Support

<tr>
<td align="center"><a href="https://github.com/kyranet"><img src="https://avatars0.githubusercontent.com/u/24852502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Antonio RomΓ‘n</b></sub></a><br /><a href="https://github.com/sapphiredev/rk/commits?author=kyranet" title="Code">πŸ’»</a> <a href="https://github.com/sapphi/sapphiredev/its?author=kyranet" title="Documentation">πŸ“–</a> <a href="#design-kyranet" title="Design">🎨</a> <a href="#ideas-kyranet" title="Ideas, Planning, & Feedback">πŸ€”</a> <a href="#infra-kyranet" title="Infrastructure (Hosting, Build-Tools, etc)">πŸš‡</a> <a href="#projectManagement-kyranet" title="Project Management">πŸ“†</a> <a href="#plugin-kyranet" title="Plugin/utility libraries">πŸ”Œ</a></td>
<td align="center"><a href="https://favware.tech/"><img src="https://avatars3.githubusercontent.com/u/4019718?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeroen Claassens</b></sub></a><br /><a href="https://github.com/sapphiredev/rk/commits?author=Favna" title="Code">πŸ’»</a> <a href="https://github.com/sapphi/sapphiredev/its?author=Favna" title="Documentation">πŸ“–</a> <a href="#infra-Favna" title="Infrastructure (Hosting, Build-Tools, etc)">πŸš‡</a> <a href="#projectManagement-Favna" title="Project Management">πŸ“†</a> <a href="#plugin-Favna" title="Plugin/utility libraries">πŸ”Œ</a></td>
<td align="center"><a href="https://github.com/cfanoulis"><img src="https://avatars3.githubusercontent.com/u/38255093?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Charalampos Fanoulis</b></sub></a><br /><a href="https://github.com/sapphiredev/rk/commits?author=cfanoulis" title="Code">πŸ’»</a></td>
<td align="center"><a href="http://www.adityatd.me"><img src="https://avatars0.githubusercontent.com/u/9266227?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aditya N. Tripathi</b></sub></a><br /><a href="https://github.com/sapphiredev/rk/commits?author=AdityaTD" title="Code">πŸ’»</a> <a href="https://github.com/sapphi/sapphiredev/its?author=AdityaTD" title="Documentation">πŸ“–</a></td>
<td align="center"><a href="http://leonard.pw"><img src="https://avatars1.githubusercontent.com/u/35312043?v=4?s=100" width="100px;" alt=""/><br /><sub><b>LeonardSSH</b></sub></a><br /><a href="https://github.com/sapphiredev/rk/commits?author=LeonardSSH" title="Documentation">πŸ“–</a></td>
<td align="center"><a href="https://quantumlytangled.com/"><img src="https://avatars1.githubusercontent.com/u/7919610?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nejc Drobnič</b></sub></a><br /><a href="https://github.com/sapphiredev/rk/commits?author=QuantumlyTangled" title="Code">πŸ’»</a> <a href="#plugin-QuantumlyTangled" title="Plugin/utility libraries">πŸ”Œ</a></td>
<td align="center"><a href="https://github.com/Phamzito"><img src="https://avatars2.githubusercontent.com/u/31642521?v=4?s=100" width="100px;" alt=""/><br /><sub><b>David Gustavo Herrera De La Cruz</b></sub></a><br /><a href="https://github.com/sapphiredev/rk/commits?author=Phamzito" title="Code">πŸ’»</a></td>
<td align="center"><a href="https://github.com/kyranet"><img src="https://avatars0.githubusercontent.com/u/24852502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Antonio RomΓ‘n</b></sub></a><br /><a href="https://github.com/sapphiredev/framework/commits?author=kyranet" title="Code">πŸ’»</a> <a href="https://github.com/sapphiredev/framework/commits?author=kyranet" title="Documentation">πŸ“–</a> <a href="#design-kyranet" title="Design">🎨</a> <a href="#ideas-kyranet" title="Ideas, Planning, & Feedback">πŸ€”</a> <a href="#infra-kyranet" title="Infrastructure (Hosting, Build-Tools, etc)">πŸš‡</a> <a href="#projectManagement-kyranet" title="Project Management">πŸ“†</a> <a href="#plugin-kyranet" title="Plugin/utility libraries">πŸ”Œ</a></td>
<td align="center"><a href="https://favware.tech/"><img src="https://avatars3.githubusercontent.com/u/4019718?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeroen Claassens</b></sub></a><br /><a href="https://github.com/sapphiredev/framework/commits?author=Favna" title="Code">πŸ’»</a> <a href="https://github.com/sapphiredev/framework/commits?author=Favna" title="Documentation">πŸ“–</a> <a href="#infra-Favna" title="Infrastructure (Hosting, Build-Tools, etc)">πŸš‡</a> <a href="#projectManagement-Favna" title="Project Management">πŸ“†</a> <a href="#plugin-Favna" title="Plugin/utility libraries">πŸ”Œ</a></td>
<td align="center"><a href="https://github.com/cfanoulis"><img src="https://avatars3.githubusercontent.com/u/38255093?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Charalampos Fanoulis</b></sub></a><br /><a href="https://github.com/sapphiredev/framework/commits?author=cfanoulis" title="Code">πŸ’»</a></td>
<td align="center"><a href="http://www.adityatd.me"><img src="https://avatars0.githubusercontent.com/u/9266227?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aditya N. Tripathi</b></sub></a><br /><a href="https://github.com/sapphiredev/framework/commits?author=AdityaTD" title="Code">πŸ’»</a> <a href="https://github.com/sapphiredev/framework/commits?author=AdityaTD" title="Documentation">πŸ“–</a></td>
<td align="center"><a href="http://leonard.pw"><img src="https://avatars1.githubusercontent.com/u/35312043?v=4?s=100" width="100px;" alt=""/><br /><sub><b>LeonardSSH</b></sub></a><br /><a href="https://github.com/sapphiredev/framework/commits?author=LeonardSSH" title="Documentation">πŸ“–</a></td>
<td align="center"><a href="https://quantumlytangled.com/"><img src="https://avatars1.githubusercontent.com/u/7919610?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nejc Drobnič</b></sub></a><br /><a href="https://github.com/sapphiredev/framework/commits?author=QuantumlyTangled" title="Code">πŸ’»</a> <a href="#plugin-QuantumlyTangled" title="Plugin/utility libraries">πŸ”Œ</a></td>
<td align="center"><a href="https://github.com/Phamzito"><img src="https://avatars2.githubusercontent.com/u/31642521?v=4?s=100" width="100px;" alt=""/><br /><sub><b>David Gustavo Herrera De La Cruz</b></sub></a><br /><a href="https://github.com/sapphiredev/framework/commits?author=Phamzito" title="Code">πŸ’»</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/Rexogamer"><img src="https://avatars0.githubusercontent.com/u/42586271?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ed L</b></sub></a><br /><a href="https://github.com/sapphiredev/rk/commits?author=Rexogamer" title="Documentation">πŸ“–</a></td>
<td align="center"><a href="https://atm.moe/"><img src="https://avatars3.githubusercontent.com/u/31011461?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kovacs Alex</b></sub></a><br /><a href="https://github.com/sapphiredev/rk/commits?author=alexthemaster" title="Code">πŸ’»</a></td>
<td align="center"><a href="https://github.com/Alcremie"><img src="https://avatars0.githubusercontent.com/u/54785334?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ivan Lieder</b></sub></a><br /><a href="https://github.com/sapphiredev/rk/commits?author=Alcremie" title="Code">πŸ’»</a> <a href="https://github.com/sapphi/sapphiredev/s?q=is%3Apr+reviewed-by%3AAlcremie" title="Reviewed Pull Requests">πŸ‘€</a></td>
<td align="center"><a href="https://github.com/Nytelife26"><img src="https://avatars1.githubusercontent.com/u/22531310?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tyler J Russell</b></sub></a><br /><a href="https://github.com/sapphiredev/rk/commits?author=Nytelife26" title="Code">πŸ’»</a> <a href="#infra-Nytelife26" title="Infrastructure (Hosting, Build-Tools, etc)">πŸš‡</a> <a href="#plugin-Nytelife26" title="Plugin/utility libraries">πŸ”Œ</a></td>
<td align="center"><a href="https://github.com/Soumil07"><img src="https://avatars0.githubusercontent.com/u/29275227?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Soumil07</b></sub></a><br /><a href="https://github.com/sapphiredev/rk/commits?author=Soumil07" title="Code">πŸ’»</a></td>
<td align="center"><a href="https://lavya.tech/"><img src="https://avatars.githubusercontent.com/u/65386243?v=4?s=100" width="100px;" alt=""/><br /><sub><b>lavgup</b></sub></a><br /><a href="https://github.com/sapphiredev/rk/commits?author=lavgup" title="Documentation">πŸ“–</a></td>
<td align="center"><a href="https://github.com/vladfrangu"><img src="https://avatars.githubusercontent.com/u/17960496?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vlad Frangu</b></sub></a><br /><a href="https://github.com/sapphiredev/rk/commits?author=vladfrangu" title="Code">πŸ’»</a> <a href="#infra-vladfrangu" title="Infrastructure (Hosting, Build-Tools, etc)">πŸš‡</a> <a href="https://github.com/sapphi/sapphiredev/s?q=is%3Apr+reviewed-by%3Avladfrangu" title="Reviewed Pull Requests">πŸ‘€</a></td>
<td align="center"><a href="https://github.com/Rexogamer"><img src="https://avatars0.githubusercontent.com/u/42586271?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ed L</b></sub></a><br /><a href="https://github.com/sapphiredev/framework/commits?author=Rexogamer" title="Documentation">πŸ“–</a></td>
<td align="center"><a href="https://atm.moe/"><img src="https://avatars3.githubusercontent.com/u/31011461?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kovacs Alex</b></sub></a><br /><a href="https://github.com/sapphiredev/framework/commits?author=alexthemaster" title="Code">πŸ’»</a></td>
<td align="center"><a href="https://github.com/Alcremie"><img src="https://avatars0.githubusercontent.com/u/54785334?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ivan Lieder</b></sub></a><br /><a href="https://github.com/sapphiredev/framework/commits?author=Alcremie" title="Code">πŸ’»</a> <a href="https://github.com/sapphiredev/framework/pulls?q=is%3Apr+reviewed-by%3AAlcremie" title="Reviewed Pull Requests">πŸ‘€</a></td>
<td align="center"><a href="https://github.com/Nytelife26"><img src="https://avatars1.githubusercontent.com/u/22531310?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tyler J Russell</b></sub></a><br /><a href="https://github.com/sapphiredev/framework/commits?author=Nytelife26" title="Code">πŸ’»</a> <a href="#infra-Nytelife26" title="Infrastructure (Hosting, Build-Tools, etc)">πŸš‡</a> <a href="#plugin-Nytelife26" title="Plugin/utility libraries">πŸ”Œ</a></td>
<td align="center"><a href="https://github.com/Soumil07"><img src="https://avatars0.githubusercontent.com/u/29275227?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Soumil07</b></sub></a><br /><a href="https://github.com/sapphiredev/framework/commits?author=Soumil07" title="Code">πŸ’»</a></td>
<td align="center"><a href="https://lavya.tech/"><img src="https://avatars.githubusercontent.com/u/65386243?v=4?s=100" width="100px;" alt=""/><br /><sub><b>lavgup</b></sub></a><br /><a href="https://github.com/sapphiredev/framework/commits?author=lavgup" title="Documentation">πŸ“–</a></td>
<td align="center"><a href="https://github.com/vladfrangu"><img src="https://avatars.githubusercontent.com/u/17960496?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vlad Frangu</b></sub></a><br /><a href="https://github.com/sapphiredev/framework/commits?author=vladfrangu" title="Code">πŸ’»</a> <a href="#infra-vladfrangu" title="Infrastructure (Hosting, Build-Tools, etc)">πŸš‡</a> <a href="https://github.com/sapphiredev/framework/pulls?q=is%3Apr+reviewed-by%3Avladfrangu" title="Reviewed Pull Requests">πŸ‘€</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/noftaly"><img src="https://avatars.githubusercontent.com/u/34779161?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Elliot</b></sub></a><br /><a href="https://github.com/sapphiredev/rk/commits?author=noftaly" title="Documentation">πŸ“–</a></td>
<td align="center"><a href="https://github.com/noftaly"><img src="https://avatars.githubusercontent.com/u/34779161?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Elliot</b></sub></a><br /><a href="https://github.com/sapphiredev/framework/commits?author=noftaly" title="Documentation">πŸ“–</a></td>
<td align="center"><a href="https://kaname.netlify.app"><img src="https://avatars.githubusercontent.com/u/56084970?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kaname</b></sub></a><br /><a href="https://github.com/sapphiredev/framework/commits?author=kaname-png" title="Code">πŸ’»</a> <a href="https://github.com/sapphiredev/framework/issues?q=author%3Akaname-png" title="Bug reports">πŸ›</a></td>
</tr>

@@ -94,0 +95,0 @@ </table>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc