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-pr-244.fc651b10.0 to 2.0.0-pr-261.c2a6471a.0

dist/index.mjs

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_js_utilities_1 = require("@sapphire/discord.js-utilities");
const ExtendedArgument_1 = require("../lib/structures/ExtendedArgument");
class CoreArgument extends ExtendedArgument_1.ExtendedArgument {
require("../lib/errors/Identifiers");
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");
class CoreArgument extends Argument_1.Argument {
constructor(context) {
super(context, {
name: 'guildCategoryChannel',
baseArgument: 'guildChannel'
});
super(context, { name: 'guildCategoryChannel' });
}
handle(channel, context) {
return discord_js_utilities_1.isCategoryChannel(channel)
? this.ok(channel)
: this.error({
parameter: context.parameter,
message: 'The argument did not resolve to a server category channel.',
context: { ...context, channel }
run(parameter, context) {
const { guild } = context.message;
if (!guild) {
return this.error({
parameter,
identifier: "guildChannelMissingGuildError" /* ArgumentGuildChannelMissingGuildError */,
message: 'This command can only be used in a server.',
context
});
}
const resolved = (0, resolvers_1.resolveGuildCategoryChannel)(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 category channel.',
context: { ...context, guild }
});
}

@@ -22,0 +31,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");

@@ -16,26 +16,19 @@ class CoreArgument extends Argument_1.Argument {

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 = this.resolveById(parameter, guild) ?? 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) {
const channelId = discord_utilities_1.ChannelMentionRegex.exec(argument) ?? discord_utilities_1.SnowflakeRegex.exec(argument);
return channelId ? guild.channels.cache.get(channelId[1]) ?? null : null;
}
resolveByQuery(argument, guild) {
const lowerCaseArgument = argument.toLowerCase();
return guild.channels.cache.find((channel) => channel.name.toLowerCase() === lowerCaseArgument) ?? null;
}
}
exports.CoreArgument = CoreArgument;
//# sourceMappingURL=CoreGuildChannel.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 ExtendedArgument_1 = require("../lib/structures/ExtendedArgument");
class CoreArgument extends ExtendedArgument_1.ExtendedArgument {
require("../lib/errors/Identifiers");
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");
class CoreArgument extends Argument_1.Argument {
constructor(context) {
super(context, {
name: 'guildNewsChannel',
baseArgument: 'guildChannel'
});
super(context, { name: 'guildNewsChannel' });
}
handle(channel, context) {
return discord_js_utilities_1.isNewsChannel(channel)
? this.ok(channel)
: this.error({
parameter: context.parameter,
message: 'The argument did not resolve to a server announcement channel.',
context: { ...context, channel }
run(parameter, context) {
const { guild } = context.message;
if (!guild) {
return this.error({
parameter,
identifier: "guildChannelMissingGuildError" /* ArgumentGuildChannelMissingGuildError */,
message: 'This command can only be used in a server.',
context
});
}
const resolved = (0, resolvers_1.resolveGuildNewsChannel)(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 valid announcements channel.',
context: { ...context, guild }
});
}

@@ -22,0 +31,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreArgument = void 0;
const ExtendedArgument_1 = require("../lib/structures/ExtendedArgument");
class CoreArgument extends ExtendedArgument_1.ExtendedArgument {
require("../lib/errors/Identifiers");
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");
class CoreArgument extends Argument_1.Argument {
constructor(context) {
super(context, {
name: 'guildNewsThreadChannel',
baseArgument: 'guildThreadChannel'
});
super(context, { name: 'guildNewsThreadChannel' });
}
handle(channel, context) {
return channel.type === 'GUILD_NEWS_THREAD'
? this.ok(channel)
: this.error({
parameter: context.parameter,
message: 'The argument did not resolve to a server announcement thread channel.',
context: { ...context, channel }
run(parameter, context) {
const { guild } = context.message;
if (!guild) {
return this.error({
parameter,
identifier: "guildChannelMissingGuildError" /* ArgumentGuildChannelMissingGuildError */,
message: 'This command can only be used in a server.',
context
});
}
const resolved = (0, resolvers_1.resolveGuildNewsThreadChannel)(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 valid announcements thread.',
context: { ...context, guild }
});
}

@@ -21,0 +31,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreArgument = void 0;
const ExtendedArgument_1 = require("../lib/structures/ExtendedArgument");
class CoreArgument extends ExtendedArgument_1.ExtendedArgument {
require("../lib/errors/Identifiers");
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");
class CoreArgument extends Argument_1.Argument {
constructor(context) {
super(context, {
name: 'guildPrivateThreadChannel',
baseArgument: 'guildThreadChannel'
});
super(context, { name: 'guildPrivateThreadChannel' });
}
handle(channel, context) {
return channel.type === 'GUILD_PRIVATE_THREAD'
? this.ok(channel)
: this.error({
parameter: context.parameter,
message: 'The argument did not resolve to a private server thread channel.',
context: { ...context, channel }
run(parameter, context) {
const { guild } = context.message;
if (!guild) {
return this.error({
parameter,
identifier: "guildChannelMissingGuildError" /* ArgumentGuildChannelMissingGuildError */,
message: 'This command can only be used in a server.',
context
});
}
const resolved = (0, resolvers_1.resolveGuildPrivateThreadChannel)(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 valid private thread.',
context: { ...context, guild }
});
}

@@ -21,0 +31,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreArgument = void 0;
const ExtendedArgument_1 = require("../lib/structures/ExtendedArgument");
class CoreArgument extends ExtendedArgument_1.ExtendedArgument {
require("../lib/errors/Identifiers");
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");
class CoreArgument extends Argument_1.Argument {
constructor(context) {
super(context, {
name: 'guildPublicThreadChannel',
baseArgument: 'guildThreadChannel'
});
super(context, { name: 'guildPublicThreadChannel' });
}
handle(channel, context) {
return channel.type === 'GUILD_PUBLIC_THREAD'
? this.ok(channel)
: this.error({
parameter: context.parameter,
message: 'The argument did not resolve to a public server thread channel.',
context: { ...context, channel }
run(parameter, context) {
const { guild } = context.message;
if (!guild) {
return this.error({
parameter,
identifier: "guildChannelMissingGuildError" /* ArgumentGuildChannelMissingGuildError */,
message: 'This command can only be used in a server.',
context
});
}
const resolved = (0, resolvers_1.resolveGuildPublicThreadChannel)(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 valid public thread.',
context: { ...context, guild }
});
}

@@ -21,0 +31,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreArgument = void 0;
const ExtendedArgument_1 = require("../lib/structures/ExtendedArgument");
class CoreArgument extends ExtendedArgument_1.ExtendedArgument {
require("../lib/errors/Identifiers");
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");
class CoreArgument extends Argument_1.Argument {
constructor(context) {
super(context, {
name: 'guildStageVoiceChannel',
baseArgument: 'guildChannel'
});
super(context, { name: 'guildStageVoiceChannel' });
}
handle(channel, context) {
return channel.type === 'GUILD_STAGE_VOICE'
? this.ok(channel)
: this.error({
parameter: context.parameter,
message: 'The argument did not resolve to a server stage voice channel.',
context: { ...context, channel }
run(parameter, context) {
const { guild } = context.message;
if (!guild) {
return this.error({
parameter,
identifier: "guildChannelMissingGuildError" /* ArgumentGuildChannelMissingGuildError */,
message: 'This command can only be used in a server.',
context
});
}
const resolved = (0, resolvers_1.resolveGuildStageVoiceChannel)(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 valid stage voice channel.',
context: { ...context, guild }
});
}

@@ -21,0 +31,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 {
require("../lib/errors/Identifiers");
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");
class CoreArgument extends Argument_1.Argument {
constructor(context) {
super(context, {
name: 'guildTextChannel',
baseArgument: 'guildChannel'
});
super(context, { name: 'guildTextChannel' });
}
handle(channel, context) {
return discord_js_utilities_1.isTextChannel(channel)
? this.ok(channel)
: this.error({
parameter: context.parameter,
message: 'The argument did not resolve to a server text channel.',
context: { ...context, channel }
run(parameter, context) {
const { guild } = context.message;
if (!guild) {
return this.error({
parameter,
identifier: "guildChannelMissingGuildError" /* ArgumentGuildChannelMissingGuildError */,
message: 'This command can only be used in a server.',
context
});
}
const resolved = (0, resolvers_1.resolveGuildTextChannel)(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 valid text channel.',
context: { ...context, guild }
});
}

@@ -22,0 +31,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreArgument = void 0;
const ExtendedArgument_1 = require("../lib/structures/ExtendedArgument");
class CoreArgument extends ExtendedArgument_1.ExtendedArgument {
require("../lib/errors/Identifiers");
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");
class CoreArgument extends Argument_1.Argument {
constructor(context) {
super(context, {
name: 'guildThreadChannel',
baseArgument: 'guildChannel'
});
super(context, { name: 'guildThreadChannel' });
}
handle(channel, context) {
return channel.isThread()
? this.ok(channel)
: this.error({
parameter: context.parameter,
message: 'The argument did not resolve to a server thread channel.',
context: { ...context, channel }
run(parameter, context) {
const { guild } = context.message;
if (!guild) {
return this.error({
parameter,
identifier: "guildChannelMissingGuildError" /* ArgumentGuildChannelMissingGuildError */,
message: 'This command can only be used in a server.',
context
});
}
const resolved = (0, resolvers_1.resolveGuildThreadChannel)(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 valid thread.',
context: { ...context, guild }
});
}

@@ -21,0 +31,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 {
require("../lib/errors/Identifiers");
const resolvers_1 = require("../lib/resolvers");
const Argument_1 = require("../lib/structures/Argument");
class CoreArgument extends Argument_1.Argument {
constructor(context) {
super(context, {
name: 'guildVoiceChannel',
baseArgument: 'guildChannel'
});
super(context, { name: 'guildVoiceChannel' });
}
handle(channel, context) {
return discord_js_utilities_1.isVoiceChannel(channel)
? this.ok(channel)
: this.error({
parameter: context.parameter,
message: 'The argument did not resolve to a server voice channel.',
context: { ...context, channel }
run(parameter, context) {
const { guild } = context.message;
if (!guild) {
return this.error({
parameter,
identifier: "guildChannelMissingGuildError" /* ArgumentGuildChannelMissingGuildError */,
message: 'This command can only be used in a server.',
context
});
}
const resolved = (0, resolvers_1.resolveGuildVoiceChannel)(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 valid voice channel.',
context: { ...context, guild }
});
}

@@ -22,0 +31,0 @@ }

"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");

@@ -17,30 +17,18 @@ class CoreArgument extends Argument_1.Argument {

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 = (await this.resolveById(parameter, guild)) ?? (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) {
const memberId = discord_utilities_1.UserOrMemberMentionRegex.exec(argument) ?? discord_utilities_1.SnowflakeRegex.exec(argument);
return memberId ? guild.members.fetch(memberId[1]).catch(() => null) : null;
}
async resolveByQuery(argument, guild) {
const members = await guild.members
.fetch({
query: argument,
limit: 1
})
.catch(() => null);
return members?.first() ?? 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");

@@ -13,37 +12,14 @@ class CoreArgument extends Argument_1.Argument {

const channel = context.channel ?? context.message.channel;
const message = (await this.resolveById(parameter, channel)) ?? (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 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 }
});
}
resolveById(argument, channel) {
return discord_js_utilities_1.SnowflakeRegex.test(argument) ? channel.messages.fetch(argument).catch(() => null) : null;
}
async resolveByLink(argument, { message }) {
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 (!channel.permissionsFor(message.author)?.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");

@@ -17,19 +17,18 @@ class CoreArgument extends Argument_1.Argument {

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 = (await this.resolveById(parameter, guild)) ?? 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) {
const roleId = discord_utilities_1.RoleMentionRegex.exec(argument) ?? discord_utilities_1.SnowflakeRegex.exec(argument);
return roleId ? guild.roles.fetch(roleId[1]).catch(() => null) : null;
}
resolveByQuery(argument, guild) {
const lowerCaseArgument = argument.toLowerCase();
return guild.roles.cache.find((role) => role.name.toLowerCase() === lowerCaseArgument) ?? 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,5 +11,11 @@ class CoreArgument extends Argument_1.Argument {

async run(parameter, context) {
const userId = discord_utilities_1.UserOrMemberMentionRegex.exec(parameter) ?? 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
});
}

@@ -16,0 +22,0 @@ }

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

run(error, context) {
const { name, path } = context.piece;
this.container.logger.error(`Encountered error on command "${name}" at path "${path}"`, error);
const { name, location } = context.piece;
this.container.logger.error(`Encountered error on command "${name}" at path "${location.full}"`, error);
}

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

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

run(error, context) {
const { name, event, path } = context.piece;
this.container.logger.error(`Encountered error on event listener "${name}" for event "${event}" at path "${path}"`, error);
const { name, event, location } = context.piece;
this.container.logger.error(`Encountered error on event listener "${name}" for event "${event}" at path "${location.full}"`, error);
}

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

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

/* Version: 2.0.0-pr-244.fc651b10.0 - August 11, 2021 22:20:04 */
/* Version: 2.0.0-pr-261.c2a6471a.0 - September 10, 2021 17:34:22 */
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = exports.StoreRegistry = 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");

@@ -16,33 +16,37 @@ var pieces_1 = require("@sapphire/pieces");

Object.defineProperty(exports, "StoreRegistry", { enumerable: true, get: function () { return pieces_1.StoreRegistry; } });
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/ExtendedArgument"), exports);
tslib_1.__exportStar(require("./lib/structures/Listener"), exports);
tslib_1.__exportStar(require("./lib/structures/ListenerStore"), exports);
tslib_1.__exportStar(require("./lib/structures/Precondition"), exports);
tslib_1.__exportStar(require("./lib/structures/PreconditionStore"), 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-pr-244.fc651b10.0';
(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-pr-261.c2a6471a.0';

@@ -6,34 +6,39 @@ "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";

@@ -49,5 +54,6 @@ Identifiers["PreconditionCooldown"] = "preconditionCooldown";

Identifiers["PreconditionNSFW"] = "preconditionNsfw";
Identifiers["PreconditionPermissions"] = "preconditionPermissions";
Identifiers["PreconditionClientPermissions"] = "preconditionClientPermissions";
Identifiers["PreconditionUserPermissions"] = "preconditionUserPermissions";
Identifiers["PreconditionThreadOnly"] = "preconditionThreadOnly";
})(Identifiers = exports.Identifiers || (exports.Identifiers = {}));
//# sourceMappingURL=Identifiers.js.map

@@ -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;

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

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

@@ -118,7 +118,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;

@@ -135,3 +135,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;

@@ -141,7 +141,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;
}

@@ -234,3 +234,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 */,

@@ -242,3 +242,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() }));
}

@@ -266,3 +266,3 @@ /**

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

@@ -274,3 +274,3 @@ /**

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

@@ -277,0 +277,0 @@ }

@@ -88,8 +88,8 @@ "use strict";

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 ListenerStore_1.ListenerStore().registerPath(path_1.join(__dirname, '..', 'listeners')))
.register(new PreconditionStore_1.PreconditionStore().registerPath(path_1.join(__dirname, '..', 'preconditions')));
.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(path_1.join(__dirname, '..', 'errorListeners'));
this.stores.get('listeners').registerPath((0, path_1.join)(__dirname, '..', 'errorListeners'));
for (const plugin of SapphireClient.plugins.values("postInitialization" /* PostInitialization */)) {

@@ -96,0 +96,0 @@ plugin.hook.call(this, options);

"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");

@@ -8,4 +8,3 @@ const pieces_1 = require("@sapphire/pieces");

const discord_js_1 = require("discord.js");
const Lexure = tslib_1.__importStar(require("lexure"));
const path_1 = require("path");
const Lexure = (0, tslib_1.__importStar)(require("lexure"));
const Args_1 = require("../parsers/Args");

@@ -24,11 +23,2 @@ require("../types/Enums");

/**
* The full category for the command. Either an array of strings that denote every (sub)folder the command is in,
* or `null` if it could not be resolved automatically.
*
* If this is `null` for how you setup your code then you can overwrite how the `fullCategory` is resolved by
* extending this class and overwriting the assignment in the constructor.
* @since 2.0.0
*/
this.fullCategory = null;
/**
* The lexer to be used for command parsing

@@ -42,2 +32,3 @@ * @since 1.0.0

this.strategy = new FlagUnorderedStrategy_1.FlagUnorderedStrategy(options);
this.fullCategory = options.fullCategory ?? this.location.directories;
this.lexer.setQuotes(options.quotes ?? [

@@ -48,15 +39,2 @@ ['"', '"'],

]);
if (options.fullCategory) {
this.fullCategory = options.fullCategory;
}
else {
const commandsFolders = [...this.container.stores.get('commands').paths.values()].map((p) => p.split(path_1.sep).pop() ?? '');
const commandPath = context.path.split(path_1.sep);
for (const commandFolder of commandsFolders) {
if (commandPath.includes(commandFolder)) {
this.fullCategory = commandPath.slice(commandPath.indexOf(commandFolder) + 1, -1);
break;
}
}
}
if (options.generateDashLessAliases) {

@@ -86,36 +64,33 @@ const dashLessAliases = [];

/**
* Get all the main categories of commands.
*/
get categories() {
return Array.from(new Set([...this.container.stores.get('commands').values()].map(({ category }) => category)));
}
/**
* The main category for the command, if any.
* This is resolved from {@link Command.fullCategory}, which is automatically
* resolved in the constructor. If you need different logic for category
* then please first look into overwriting {@link Command.fullCategory} before
* looking to overwrite this getter.
*
* 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) > 0 ? this.fullCategory?.[0] ?? null : null;
return this.fullCategory.length > 0 ? this.fullCategory[0] : null;
}
/**
* The sub category for the command
* This is resolved from {@link Command.fullCategory}, which is automatically
* resolved in the constructor. If you need different logic for category
* then please first look into overwriting {@link Command.fullCategory} before
* looking to overwrite this getter.
* 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 ?? 0) > 1 ? this.fullCategory?.[1] ?? null : null;
return this.fullCategory.length > 1 ? this.fullCategory[1] : null;
}
/**
* The parent category for the command
* This is resolved from {@link Command.fullCategory}, which is automatically
* resolved in the constructor. If you need different logic for category
* then please first look into overwriting {@link Command.fullCategory} before
* looking to overwrite this getter.
* 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 ?? 0) > 0 ? this.fullCategory?.[(this.fullCategory?.length ?? 1) - 1] ?? null : null;
return this.fullCategory.length > 1 ? this.fullCategory[this.fullCategory.length - 1] : null;
}

@@ -130,3 +105,3 @@ /**

detailedDescription: this.detailedDescription,
strategy: this.strategy
category: this.category
};

@@ -146,2 +121,3 @@ }

this.parseConstructorPreConditionsRequiredClientPermissions(options);
this.parseConstructorPreConditionsRequiredUserPermissions(options);
this.parseConstructorPreConditionsCooldown(options);

@@ -169,3 +145,3 @@ }

/**
* Appends the `Permissions` precondition when {@link CommandOptions.requiredClientPermissions} resolves to a
* Appends the `ClientPermissions` precondition when {@link CommandOptions.requiredClientPermissions} resolves to a
* non-zero bitfield.

@@ -177,6 +153,17 @@ * @param options The command options given from the constructor.

if (permissions.bitfield !== 0n) {
this.preconditions.append({ name: "Permissions" /* Permissions */, context: { permissions } });
this.preconditions.append({ name: "ClientPermissions" /* ClientPermissions */, context: { permissions } });
}
}
/**
* 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

@@ -189,6 +176,7 @@ * {@link CommandOptions.cooldownDelay} are both non-zero.

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 }
context: { scope: options.cooldownScope ?? 3 /* User */, limit, delay, filteredUsers }
});

@@ -198,3 +186,3 @@ }

resolveConstructorPreConditionsRunType(runIn) {
if (utilities_1.isNullish(runIn))
if ((0, utilities_1.isNullish)(runIn))
return null;

@@ -274,2 +262,16 @@ if (typeof runIn === 'string') {

/**
* 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.

@@ -290,4 +292,5 @@ * @since 2.0.0

CommandPreConditions["NotSafeForWork"] = "NSFW";
CommandPreConditions["Permissions"] = "Permissions";
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 @@ }

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

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

@@ -21,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 }));
}

@@ -24,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) {

@@ -13,6 +13,6 @@ "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)();
},

@@ -23,5 +23,5 @@ async parallel(message, command, entries, context) {

// However, the base implementation short-circuits with the first Ok.
return results.find(Result_1.isErr) ?? 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 ?? 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 ?? Result_1.ok();
return error ?? (0, Result_1.ok)();
}
};
//# sourceMappingURL=PreconditionConditionOr.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreListener = void 0;
const discord_js_utilities_1 = require("@sapphire/discord.js-utilities");
const discord_js_1 = require("discord.js");

@@ -43,3 +44,3 @@ const Listener_1 = require("../../lib/structures/Listener");

async canRunInChannel(message) {
if (message.channel.type === 'DM')
if ((0, discord_js_utilities_1.isDMChannel)(message.channel))
return true;

@@ -46,0 +47,0 @@ const me = message.guild.me ?? (message.client.id ? await message.guild.members.fetch(message.client.id) : null);

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

return this.ok();
// 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));

@@ -22,0 +25,0 @@ if (ratelimit.limited) {

{
"name": "@sapphire/framework",
"version": "2.0.0-pr-244.fc651b10.0",
"version": "2.0.0-pr-261.c2a6471a.0",
"description": "Discord bot framework built on top of @sapphire/lib for advanced and amazing bots.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"exports": {
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
"author": "@sapphire",

@@ -19,2 +23,3 @@ "license": "MIT",

"build": "tsc -b src && rollup -c scripts/rollup.bundle.ts",
"postbuild": "gen-esm-wrapper dist/index.js dist/index.mjs",
"watch": "tsc -b src -w",

@@ -30,7 +35,7 @@ "sversion": "standard-version",

"@sapphire/discord.js-utilities": "next",
"@sapphire/pieces": "^2.1.0",
"@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"
},

@@ -40,2 +45,3 @@ "devDependencies": {

"@commitlint/config-conventional": "^13.1.0",
"@favware/npm-deprecate": "^1.0.2",
"@favware/rollup-type-bundler": "^1.0.3",

@@ -45,20 +51,21 @@ "@sapphire/eslint-config": "^3.2.3",

"@sapphire/ts-config": "^3.0.0",
"@types/jest": "^26.0.24",
"@types/node": "^16.4.13",
"@types/jest": "^27.0.1",
"@types/node": "^16.7.10",
"@types/ws": "^7.4.7",
"cz-conventional-changelog": "^3.3.0",
"discord.js": "^13.0.0",
"husky": "^7.0.1",
"jest": "^27.0.6",
"jest-circus": "^27.0.6",
"discord.js": "^13.1.0",
"gen-esm-wrapper": "^1.1.2",
"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.56.0",
"rollup": "^2.56.3",
"rollup-plugin-version-injector": "^1.3.3",
"standard-version": "^9.3.1",
"ts-jest": "^27.0.4",
"ts-node": "^10.1.0",
"typedoc": "^0.21.5",
"ts-jest": "^27.0.5",
"ts-node": "^10.2.1",
"typedoc": "^0.21.9",
"typedoc-plugin-nojekyll": "^1.0.1",
"typescript": "^4.3.5"
"typescript": "^4.4.2"
},

@@ -65,0 +72,0 @@ "repository": {

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

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

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