@sapphire/decorators 6.1.2-next.4844417e → 6.1.2-next.5d7bdbbc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +3 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +3 -3
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/cjs/index.cjs
CHANGED
|
@@ -17,7 +17,7 @@ function createClassDecorator(fn) {
|
|
|
17
17
|
return fn;
|
|
18
18
|
}
|
|
19
19
|
__name(createClassDecorator, "createClassDecorator");
|
|
20
|
-
function createFunctionPrecondition(precondition, fallback = () =>
|
|
20
|
+
function createFunctionPrecondition(precondition, fallback = () => undefined) {
|
|
21
21
|
return createMethodDecorator((_target, _propertyKey, descriptor) => {
|
|
22
22
|
const method = descriptor.value;
|
|
23
23
|
if (!method) throw new Error("Function preconditions require a [[value]].");
|
|
@@ -149,11 +149,11 @@ var RequiresUserPermissions = /* @__PURE__ */ __name((...permissionsResolvable)
|
|
|
149
149
|
return true;
|
|
150
150
|
});
|
|
151
151
|
}, "RequiresUserPermissions");
|
|
152
|
-
function RequiresGuildContext(fallback = () =>
|
|
152
|
+
function RequiresGuildContext(fallback = () => undefined) {
|
|
153
153
|
return createFunctionPrecondition((context) => context.guild !== null, fallback);
|
|
154
154
|
}
|
|
155
155
|
__name(RequiresGuildContext, "RequiresGuildContext");
|
|
156
|
-
function RequiresDMContext(fallback = () =>
|
|
156
|
+
function RequiresDMContext(fallback = () => undefined) {
|
|
157
157
|
return createFunctionPrecondition((context) => context.guild === null, fallback);
|
|
158
158
|
}
|
|
159
159
|
__name(RequiresDMContext, "RequiresDMContext");
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils.ts","../../src/base-decorators.ts","../../src/djs-decorators.ts","../../src/piece-decorators.ts"],"names":["target","DecoratorIdentifiers","Permissions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AAa,YAAY,aAAEG,mBAAA,EAAW,OAAQ,EAAC,CAAI,GAAA;AAAA,OAC9E,CAJS,EAAA,WAAA;AAAA,KAKX;AAAA,GACF;AACD;AAVgB,MAAA,CAAA,YAAA,EAAA,cAAA,CAAA","file":"index.cjs","sourcesContent":["/**\n * The function precondition interface.\n */\nexport interface FunctionPrecondition {\n\t/**\n\t * The arguments passed to the function or class' method.\n\t */\n\t(...args: any[]): boolean | Promise<boolean>;\n}\n\n/**\n * The fallback interface, this is called when the function precondition returns or resolves with a falsy value.\n */\nexport interface FunctionFallback {\n\t/**\n\t * The arguments passed to the function or class' method.\n\t */\n\t(...args: any[]): unknown;\n}\n\n/**\n * Utility to make a method decorator with lighter syntax and inferred types.\n *\n * ```typescript\n * // Enumerable function\n *\tfunction enumerableMethod(value: boolean) {\n *\t\treturn createMethodDecorator((_target, _propertyKey, descriptor) => {\n *\t\t\tdescriptor.enumerable = value;\n *\t\t});\n *\t}\n * ```\n * @param fn The method to decorate\n */\nexport function createMethodDecorator(fn: MethodDecorator): MethodDecorator {\n\treturn fn;\n}\n\n/**\n * Utility to make a class decorator with lighter syntax and inferred types.\n * @param fn The class to decorate\n * @see {@link ApplyOptions}\n */\nexport function createClassDecorator<TFunction extends (...args: any[]) => void>(fn: TFunction): ClassDecorator {\n\treturn fn;\n}\n\n/**\n * Utility to make function preconditions.\n *\n * ```typescript\n * // No fallback (returns undefined)\n * function requireGuild(value: number) {\n * return createFunctionPrecondition((message: Message) =>\n * message.guild !== null\n * );\n * }\n *\n * // With fallback\n * function requireGuild(\n * value: number,\n * fallback: () => unknown = () => undefined\n * ) {\n * return createFunctionPrecondition(\n * (message: Message) => message.guild !== null,\n * fallback\n * );\n * }\n * ```\n * @since 1.0.0\n * @param precondition The function that defines whether or not the function should be run, returning the returned value from fallback\n * @param fallback The fallback value that defines what the method should return in case the precondition fails\n */\nexport function createFunctionPrecondition(precondition: FunctionPrecondition, fallback: FunctionFallback = (): void => undefined): MethodDecorator {\n\treturn createMethodDecorator((_target, _propertyKey, descriptor) => {\n\t\tconst method = descriptor.value;\n\t\tif (!method) throw new Error('Function preconditions require a [[value]].');\n\t\tif (typeof method !== 'function') throw new Error('Function preconditions can only be applied to functions.');\n\n\t\tdescriptor.value = async function descriptorValue(this: (...args: any[]) => any, ...args: any[]) {\n\t\t\tconst canRun = await precondition(...args);\n\t\t\treturn canRun ? method.call(this, ...args) : fallback.call(this, ...args);\n\t\t} as unknown as undefined;\n\t});\n}\n\n/**\n * Creates a new proxy to efficiently add properties to class without creating subclasses\n * @param target The constructor of the class to modify\n * @param handler The handler function to modify the constructor behavior for the target\n * @hidden\n */\nexport function createProxy<T extends object>(target: T, handler: Omit<ProxyHandler<T>, 'get'>): T {\n\treturn new Proxy(target, {\n\t\t...handler,\n\t\tget: (target, property) => {\n\t\t\tconst value = Reflect.get(target, property);\n\t\t\treturn typeof value === 'function' ? (...args: readonly unknown[]) => value.apply(target, args) : value;\n\t\t}\n\t});\n}\n","import { createMethodDecorator } from './utils';\n\n/**\n * Decorator that sets the enumerable property of a class field to the desired value.\n * @param value Whether the property should be enumerable or not\n */\nexport function Enumerable(value: boolean) {\n\treturn (target: object, key: string) => {\n\t\tReflect.defineProperty(target, key, {\n\t\t\tenumerable: value,\n\t\t\tset(this: unknown, val: unknown) {\n\t\t\t\tReflect.defineProperty(this as object, key, {\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t\tenumerable: value,\n\t\t\t\t\tvalue: val,\n\t\t\t\t\twritable: true\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t};\n}\n\n/**\n * Decorator that sets the enumerable property of a class method to the desired value.\n * @param value Whether the method should be enumerable or not\n */\nexport function EnumerableMethod(value: boolean) {\n\treturn createMethodDecorator((_target, _propertyKey, descriptor) => {\n\t\tdescriptor.enumerable = value;\n\t});\n}\n","import { isDMChannel, isGuildBasedChannel } from '@sapphire/discord.js-utilities';\nimport { UserError } from '@sapphire/framework';\nimport { isNullish } from '@sapphire/utilities';\nimport { PermissionFlagsBits, PermissionsBitField, type BaseInteraction, type Message, type PermissionResolvable } from 'discord.js';\nimport { createFunctionPrecondition, type FunctionFallback } from './utils';\n\nexport enum DecoratorIdentifiers {\n\tRequiresClientPermissionsGuildOnly = 'requiresClientPermissionsGuildOnly',\n\tRequiresClientPermissionsMissingPermissions = 'requiresClientPermissionsMissingPermissions',\n\tRequiresUserPermissionsGuildOnly = 'requiresUserPermissionsGuildOnly',\n\tRequiresUserPermissionsMissingPermissions = 'requiresUserPermissionsMissingPermissions'\n}\n\nconst DMAvailablePermissions = new PermissionsBitField(\n\t~new PermissionsBitField([\n\t\t//\n\t\tPermissionFlagsBits.AddReactions,\n\t\tPermissionFlagsBits.AttachFiles,\n\t\tPermissionFlagsBits.EmbedLinks,\n\t\tPermissionFlagsBits.ReadMessageHistory,\n\t\tPermissionFlagsBits.SendMessages,\n\t\tPermissionFlagsBits.UseExternalEmojis,\n\t\tPermissionFlagsBits.ViewChannel\n\t]).bitfield & PermissionsBitField.All\n);\n\nconst DMAvailableUserPermissions = new PermissionsBitField(\n\t~new PermissionsBitField([\n\t\tPermissionFlagsBits.AddReactions,\n\t\tPermissionFlagsBits.AttachFiles,\n\t\tPermissionFlagsBits.EmbedLinks,\n\t\tPermissionFlagsBits.ReadMessageHistory,\n\t\tPermissionFlagsBits.SendMessages,\n\t\tPermissionFlagsBits.UseExternalEmojis,\n\t\tPermissionFlagsBits.ViewChannel,\n\t\tPermissionFlagsBits.UseExternalStickers,\n\t\tPermissionFlagsBits.MentionEveryone\n\t]).bitfield & PermissionsBitField.All\n);\n\n/**\n * Allows you to set permissions required for individual methods. This is particularly useful for subcommands that require specific permissions.\n * @remark This decorator applies to the client that is to execute the command. For setting permissions required user of the command see {@link RequiresUserPermissions}\n * @remark This decorator makes the decorated function asynchronous, so any result should be `await`ed.\n * @param permissionsResolvable Permissions that the method should have.\n * @example\n * ```typescript\n * import { ApplyOptions, RequiresClientPermissions } from '@sapphire/decorators';\n * import { Subcommand } from '@sapphire/plugin-subcommands';\n * import type { Message } from 'discord.js';\n *\n * (at)ApplyOptions<Subcommand.Options>({\n * \taliases: ['cws'],\n * \tdescription: 'A basic command with some subcommands',\n * \tsubCommands: ['add', 'remove', 'reset', { input: 'show', default: true }]\n * })\n * export default class extends Subcommand {\n * // Anyone should be able to view the result, but not modify\n * \tpublic async show(message: Message) {\n * \t\treturn message.channel.send('Showing!');\n * \t}\n *\n * \t(at)RequiresClientPermissions('BAN_MEMBERS') // This subcommand requires the client to be able to ban members.\n * \tpublic async add(message: Message) {\n * \t\treturn message.channel.send('Adding!');\n * \t}\n *\n * \t(at)RequiresClientPermissions('BAN_MEMBERS') // This subcommand requires the client to be able to ban members.\n * \tpublic async remove(message: Message) {\n * \t\treturn message.channel.send('Removing!');\n * \t}\n *\n * \t(at)RequiresClientPermissions('BAN_MEMBERS') // This subcommand requires the client to be able to ban members.\n * \tpublic async reset(message: Message) {\n * \t\treturn message.channel.send('Resetting!');\n * \t}\n * }\n * ```\n */\nexport const RequiresClientPermissions = (...permissionsResolvable: PermissionResolvable[]): MethodDecorator => {\n\tconst resolved = new PermissionsBitField(permissionsResolvable);\n\tconst resolvedIncludesServerPermissions = Boolean(resolved.bitfield & DMAvailablePermissions.bitfield);\n\n\treturn createFunctionPrecondition((context: Message | BaseInteraction) => {\n\t\tconst { channel } = context;\n\t\tconst member = context.guild?.members.me;\n\n\t\tif (resolvedIncludesServerPermissions && isDMChannel(channel)) {\n\t\t\tthrow new UserError({\n\t\t\t\tidentifier: DecoratorIdentifiers.RequiresClientPermissionsGuildOnly,\n\t\t\t\tmessage: 'Sorry, but that command can only be used in a server because I do not have sufficient permissions in DMs'\n\t\t\t});\n\t\t}\n\n\t\tif (isGuildBasedChannel(channel) && !isNullish(member)) {\n\t\t\tconst missingPermissions = channel.permissionsFor(member).missing(resolved);\n\n\t\t\tif (missingPermissions.length) {\n\t\t\t\tthrow new UserError({\n\t\t\t\t\tidentifier: DecoratorIdentifiers.RequiresClientPermissionsMissingPermissions,\n\t\t\t\t\tmessage: `Sorry, but I am not allowed to do that. I am missing the permissions: ${missingPermissions}`,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tmissing: missingPermissions\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t});\n};\n\n/**\n * Allows you to set permissions required for individual methods. This is particularly useful for subcommands that require specific permissions.\n * @remark This decorator applies to the user of the command. For setting permissions required for the client see {@link RequiresClientPermissions}\n * @remark This decorator makes the decorated function asynchronous, so any result should be `await`ed.\n * @param permissionsResolvable Permissions that the method should have.\n * @example\n * ```typescript\n * import { ApplyOptions, RequiresUserPermissions } from '@sapphire/decorators';\n * import { Subcommand } from '@sapphire/plugin-subcommands';\n * import type { Message } from 'discord.js';\n *\n * (at)ApplyOptions<Subcommand.Options>({\n * \taliases: ['cws'],\n * \tdescription: 'A basic command with some subcommands',\n * \tsubCommands: ['add', 'remove', 'reset', { input: 'show', default: true }]\n * })\n * export default class extends Subcommand {\n * // Anyone should be able to view the result, but not modify\n * \tpublic async show(message: Message) {\n * \t\treturn message.channel.send('Showing!');\n * \t}\n *\n * \t(at)RequiresUserPermissions('BAN_MEMBERS') // This subcommand requires the user of the command to be able to ban members.\n * \tpublic async add(message: Message) {\n * \t\treturn message.channel.send('Adding!');\n * \t}\n *\n * \t(at)RequiresUserPermissions('BAN_MEMBERS') // This subcommand requires the user of the command to be able to ban members.\n * \tpublic async remove(message: Message) {\n * \t\treturn message.channel.send('Removing!');\n * \t}\n *\n * \t(at)RequiresUserPermissions('BAN_MEMBERS') // This subcommand requires the user of the command to be able to ban members.\n * \tpublic async reset(message: Message) {\n * \t\treturn message.channel.send('Resetting!');\n * \t}\n * }\n * ```\n */\nexport const RequiresUserPermissions = (...permissionsResolvable: PermissionResolvable[]): MethodDecorator => {\n\tconst resolved = new PermissionsBitField(permissionsResolvable);\n\tconst resolvedIncludesServerPermissions = Boolean(resolved.bitfield & DMAvailableUserPermissions.bitfield);\n\n\treturn createFunctionPrecondition((context: Message | BaseInteraction) => {\n\t\tconst { channel } = context;\n\t\tconst member = context.guild?.members.me;\n\n\t\tif (resolvedIncludesServerPermissions && isDMChannel(channel)) {\n\t\t\tthrow new UserError({\n\t\t\t\tidentifier: DecoratorIdentifiers.RequiresUserPermissionsGuildOnly,\n\t\t\t\tmessage: 'Sorry, but that command can only be used in a server because you do not have sufficient permissions in DMs'\n\t\t\t});\n\t\t}\n\n\t\tif (isGuildBasedChannel(channel) && !isNullish(member)) {\n\t\t\tconst missingPermissions = channel.permissionsFor(member).missing(resolved);\n\n\t\t\tif (missingPermissions.length) {\n\t\t\t\tthrow new UserError({\n\t\t\t\t\tidentifier: DecoratorIdentifiers.RequiresUserPermissionsMissingPermissions,\n\t\t\t\t\tmessage: `Sorry, but you are not allowed to do that. You are missing the permissions: ${missingPermissions}`,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tmissing: missingPermissions\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t});\n};\n\n/**\n * Requires the message to be run in a guild context, this decorator requires the first argument to be a {@link Message} or {@link BaseInteraction} instance which includes all interaction types\n * @since 1.0.0\n * @param fallback The fallback value passed to {@link createFunctionPrecondition}\n */\nexport function RequiresGuildContext(fallback: FunctionFallback = (): void => undefined): MethodDecorator {\n\treturn createFunctionPrecondition((context: Message | BaseInteraction) => context.guild !== null, fallback);\n}\n\n/**\n * Requires the message to be run in a dm context, this decorator requires the first argument to be a {@link Message} or {@link BaseInteraction} instance which includes all interaction types\n * @since 1.0.0\n * @param fallback The fallback value passed to {@link createFunctionPrecondition}\n */\nexport function RequiresDMContext(fallback: FunctionFallback = (): void => undefined): MethodDecorator {\n\treturn createFunctionPrecondition((context: Message | BaseInteraction) => context.guild === null, fallback);\n}\n","import { container, type Piece } from '@sapphire/framework';\nimport type { Container } from '@sapphire/pieces';\nimport type { Ctor } from '@sapphire/utilities';\nimport { createClassDecorator, createProxy } from './utils';\n\n/**\n * Decorator function that applies given options to any Sapphire piece\n * @param optionsOrFn The options or function that returns options to pass to the piece constructor\n * @example\n * ```typescript\n * import { ApplyOptions } from '@sapphire/decorators';\n * import { Command } from '@sapphire/framework';\n * import type { Message } from 'discord.js';\n *\n * @ApplyOptions<Command.Options>({\n * description: 'ping pong',\n * enabled: true\n * })\n * export class UserCommand extends Command {\n * public override async messageRun(message: Message) {\n * const msg = await message.channel.send('Ping?');\n *\n * return msg.edit(\n * `Pong! Client Latency ${Math.round(this.container.client.ws.ping)}ms. API Latency ${msg.createdTimestamp - message.createdTimestamp}ms.`\n * );\n * }\n * }\n * ```\n * @example\n * ```typescript\n * import { ApplyOptions } from '@sapphire/decorators';\n * import { Listener } from '@sapphire/framework';\n * import { GatewayDispatchEvents, GatewayMessageDeleteDispatch } from 'discord.js';\n *\n * @ApplyOptions<Listener.Options>(({ container }) => ({\n * description: 'Handle Raw Message Delete events',\n * emitter: container.client.ws,\n * event: GatewayDispatchEvents.MessageDelete\n * }))\n * export class UserListener extends Listener {\n * public override run(data: GatewayMessageDeleteDispatch['d']): void {\n * if (!data.guild_id) return;\n *\n * const guild = this.container.client.guilds.cache.get(data.guild_id);\n * if (!guild || !guild.channels.cache.has(data.channel_id)) return;\n *\n * // Do something with the data\n * }\n * }\n * ```\n */\nexport function ApplyOptions<T extends Piece.Options>(optionsOrFn: T | ((parameters: ApplyOptionsCallbackParameters) => T)): ClassDecorator {\n\treturn createClassDecorator((target: Ctor<ConstructorParameters<typeof Piece>, Piece>) =>\n\t\tcreateProxy(target, {\n\t\t\tconstruct: (ctor, [context, baseOptions = {}]: [Piece.LoaderContext, Piece.Options]) =>\n\t\t\t\tnew ctor(context, {\n\t\t\t\t\t...baseOptions,\n\t\t\t\t\t...(typeof optionsOrFn === 'function' ? optionsOrFn({ container, context }) : optionsOrFn)\n\t\t\t\t})\n\t\t})\n\t);\n}\n\nexport interface ApplyOptionsCallbackParameters {\n\tcontainer: Container;\n\tcontext: Piece.LoaderContext;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils.ts","../../src/base-decorators.ts","../../src/djs-decorators.ts","../../src/piece-decorators.ts"],"names":["target","DecoratorIdentifiers","PermissionsBitField","PermissionFlagsBits","isDMChannel","UserError","isGuildBasedChannel","isNullish","container"],"mappings":";;;;;;;;;;;AAiCO,SAAS,sBAAsB,EAAsC,EAAA;AAC3E,EAAO,OAAA,EAAA;AACR;AAFgB,MAAA,CAAA,qBAAA,EAAA,uBAAA,CAAA;AAST,SAAS,qBAAiE,EAA+B,EAAA;AAC/G,EAAO,OAAA,EAAA;AACR;AAFgB,MAAA,CAAA,oBAAA,EAAA,sBAAA,CAAA;AA8BT,SAAS,0BAA2B,CAAA,YAAA,EAAoC,QAA6B,GAAA,MAAY,SAA4B,EAAA;AACnJ,EAAA,OAAO,qBAAsB,CAAA,CAAC,OAAS,EAAA,YAAA,EAAc,UAAe,KAAA;AACnE,IAAA,MAAM,SAAS,UAAW,CAAA,KAAA;AAC1B,IAAA,IAAI,CAAC,MAAA,EAAc,MAAA,IAAI,MAAM,6CAA6C,CAAA;AAC1E,IAAA,IAAI,OAAO,MAAW,KAAA,UAAA,EAAkB,MAAA,IAAI,MAAM,0DAA0D,CAAA;AAE5G,IAAW,UAAA,CAAA,KAAA,mBAAuB,MAAA,CAAA,eAAA,eAAA,CAAA,GAAkD,IAAa,EAAA;AAChG,MAAA,MAAM,MAAS,GAAA,MAAM,YAAa,CAAA,GAAG,IAAI,CAAA;AACzC,MAAO,OAAA,MAAA,GAAS,MAAO,CAAA,IAAA,CAAK,IAAM,EAAA,GAAG,IAAI,CAAA,GAAI,QAAS,CAAA,IAAA,CAAK,IAAM,EAAA,GAAG,IAAI,CAAA;AAAA,KAFtD,EAAA,iBAAA,CAAA;AAAA,GAInB,CAAA;AACF;AAXgB,MAAA,CAAA,0BAAA,EAAA,4BAAA,CAAA;AAmBT,SAAS,WAAA,CAA8B,QAAW,OAA0C,EAAA;AAClG,EAAO,OAAA,IAAI,MA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KAC3C,IAAI,IAAA,CAAK,OAAS,EAAA;AAAA,QACjB,GAAG,WAAA;AAAA,QACH,GAAI,OAAO,WAAgB,KAAA,UAAA,GAAa,YAAY,aAAEG,mBAAA,EAAW,OAAQ,EAAC,CAAI,GAAA;AAAA,OAC9E,CAJS,EAAA,WAAA;AAAA,KAKX;AAAA,GACF;AACD;AAVgB,MAAA,CAAA,YAAA,EAAA,cAAA,CAAA","file":"index.cjs","sourcesContent":["/**\n * The function precondition interface.\n */\nexport interface FunctionPrecondition {\n\t/**\n\t * The arguments passed to the function or class' method.\n\t */\n\t(...args: any[]): boolean | Promise<boolean>;\n}\n\n/**\n * The fallback interface, this is called when the function precondition returns or resolves with a falsy value.\n */\nexport interface FunctionFallback {\n\t/**\n\t * The arguments passed to the function or class' method.\n\t */\n\t(...args: any[]): unknown;\n}\n\n/**\n * Utility to make a method decorator with lighter syntax and inferred types.\n *\n * ```typescript\n * // Enumerable function\n *\tfunction enumerableMethod(value: boolean) {\n *\t\treturn createMethodDecorator((_target, _propertyKey, descriptor) => {\n *\t\t\tdescriptor.enumerable = value;\n *\t\t});\n *\t}\n * ```\n * @param fn The method to decorate\n */\nexport function createMethodDecorator(fn: MethodDecorator): MethodDecorator {\n\treturn fn;\n}\n\n/**\n * Utility to make a class decorator with lighter syntax and inferred types.\n * @param fn The class to decorate\n * @see {@link ApplyOptions}\n */\nexport function createClassDecorator<TFunction extends (...args: any[]) => void>(fn: TFunction): ClassDecorator {\n\treturn fn;\n}\n\n/**\n * Utility to make function preconditions.\n *\n * ```typescript\n * // No fallback (returns undefined)\n * function requireGuild(value: number) {\n * return createFunctionPrecondition((message: Message) =>\n * message.guild !== null\n * );\n * }\n *\n * // With fallback\n * function requireGuild(\n * value: number,\n * fallback: () => unknown = () => undefined\n * ) {\n * return createFunctionPrecondition(\n * (message: Message) => message.guild !== null,\n * fallback\n * );\n * }\n * ```\n * @since 1.0.0\n * @param precondition The function that defines whether or not the function should be run, returning the returned value from fallback\n * @param fallback The fallback value that defines what the method should return in case the precondition fails\n */\nexport function createFunctionPrecondition(precondition: FunctionPrecondition, fallback: FunctionFallback = (): void => undefined): MethodDecorator {\n\treturn createMethodDecorator((_target, _propertyKey, descriptor) => {\n\t\tconst method = descriptor.value;\n\t\tif (!method) throw new Error('Function preconditions require a [[value]].');\n\t\tif (typeof method !== 'function') throw new Error('Function preconditions can only be applied to functions.');\n\n\t\tdescriptor.value = async function descriptorValue(this: (...args: any[]) => any, ...args: any[]) {\n\t\t\tconst canRun = await precondition(...args);\n\t\t\treturn canRun ? method.call(this, ...args) : fallback.call(this, ...args);\n\t\t} as unknown as undefined;\n\t});\n}\n\n/**\n * Creates a new proxy to efficiently add properties to class without creating subclasses\n * @param target The constructor of the class to modify\n * @param handler The handler function to modify the constructor behavior for the target\n * @hidden\n */\nexport function createProxy<T extends object>(target: T, handler: Omit<ProxyHandler<T>, 'get'>): T {\n\treturn new Proxy(target, {\n\t\t...handler,\n\t\tget: (target, property) => {\n\t\t\tconst value = Reflect.get(target, property);\n\t\t\treturn typeof value === 'function' ? (...args: readonly unknown[]) => value.apply(target, args) : value;\n\t\t}\n\t});\n}\n","import { createMethodDecorator } from './utils';\n\n/**\n * Decorator that sets the enumerable property of a class field to the desired value.\n * @param value Whether the property should be enumerable or not\n */\nexport function Enumerable(value: boolean) {\n\treturn (target: object, key: string) => {\n\t\tReflect.defineProperty(target, key, {\n\t\t\tenumerable: value,\n\t\t\tset(this: unknown, val: unknown) {\n\t\t\t\tReflect.defineProperty(this as object, key, {\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t\tenumerable: value,\n\t\t\t\t\tvalue: val,\n\t\t\t\t\twritable: true\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t};\n}\n\n/**\n * Decorator that sets the enumerable property of a class method to the desired value.\n * @param value Whether the method should be enumerable or not\n */\nexport function EnumerableMethod(value: boolean) {\n\treturn createMethodDecorator((_target, _propertyKey, descriptor) => {\n\t\tdescriptor.enumerable = value;\n\t});\n}\n","import { isDMChannel, isGuildBasedChannel } from '@sapphire/discord.js-utilities';\nimport { UserError } from '@sapphire/framework';\nimport { isNullish } from '@sapphire/utilities';\nimport { PermissionFlagsBits, PermissionsBitField, type BaseInteraction, type Message, type PermissionResolvable } from 'discord.js';\nimport { createFunctionPrecondition, type FunctionFallback } from './utils';\n\nexport enum DecoratorIdentifiers {\n\tRequiresClientPermissionsGuildOnly = 'requiresClientPermissionsGuildOnly',\n\tRequiresClientPermissionsMissingPermissions = 'requiresClientPermissionsMissingPermissions',\n\tRequiresUserPermissionsGuildOnly = 'requiresUserPermissionsGuildOnly',\n\tRequiresUserPermissionsMissingPermissions = 'requiresUserPermissionsMissingPermissions'\n}\n\nconst DMAvailablePermissions = new PermissionsBitField(\n\t~new PermissionsBitField([\n\t\t//\n\t\tPermissionFlagsBits.AddReactions,\n\t\tPermissionFlagsBits.AttachFiles,\n\t\tPermissionFlagsBits.EmbedLinks,\n\t\tPermissionFlagsBits.ReadMessageHistory,\n\t\tPermissionFlagsBits.SendMessages,\n\t\tPermissionFlagsBits.UseExternalEmojis,\n\t\tPermissionFlagsBits.ViewChannel\n\t]).bitfield & PermissionsBitField.All\n);\n\nconst DMAvailableUserPermissions = new PermissionsBitField(\n\t~new PermissionsBitField([\n\t\tPermissionFlagsBits.AddReactions,\n\t\tPermissionFlagsBits.AttachFiles,\n\t\tPermissionFlagsBits.EmbedLinks,\n\t\tPermissionFlagsBits.ReadMessageHistory,\n\t\tPermissionFlagsBits.SendMessages,\n\t\tPermissionFlagsBits.UseExternalEmojis,\n\t\tPermissionFlagsBits.ViewChannel,\n\t\tPermissionFlagsBits.UseExternalStickers,\n\t\tPermissionFlagsBits.MentionEveryone\n\t]).bitfield & PermissionsBitField.All\n);\n\n/**\n * Allows you to set permissions required for individual methods. This is particularly useful for subcommands that require specific permissions.\n * @remark This decorator applies to the client that is to execute the command. For setting permissions required user of the command see {@link RequiresUserPermissions}\n * @remark This decorator makes the decorated function asynchronous, so any result should be `await`ed.\n * @param permissionsResolvable Permissions that the method should have.\n * @example\n * ```typescript\n * import { ApplyOptions, RequiresClientPermissions } from '@sapphire/decorators';\n * import { Subcommand } from '@sapphire/plugin-subcommands';\n * import type { Message } from 'discord.js';\n *\n * (at)ApplyOptions<Subcommand.Options>({\n * \taliases: ['cws'],\n * \tdescription: 'A basic command with some subcommands',\n * \tsubCommands: ['add', 'remove', 'reset', { input: 'show', default: true }]\n * })\n * export default class extends Subcommand {\n * // Anyone should be able to view the result, but not modify\n * \tpublic async show(message: Message) {\n * \t\treturn message.channel.send('Showing!');\n * \t}\n *\n * \t(at)RequiresClientPermissions('BAN_MEMBERS') // This subcommand requires the client to be able to ban members.\n * \tpublic async add(message: Message) {\n * \t\treturn message.channel.send('Adding!');\n * \t}\n *\n * \t(at)RequiresClientPermissions('BAN_MEMBERS') // This subcommand requires the client to be able to ban members.\n * \tpublic async remove(message: Message) {\n * \t\treturn message.channel.send('Removing!');\n * \t}\n *\n * \t(at)RequiresClientPermissions('BAN_MEMBERS') // This subcommand requires the client to be able to ban members.\n * \tpublic async reset(message: Message) {\n * \t\treturn message.channel.send('Resetting!');\n * \t}\n * }\n * ```\n */\nexport const RequiresClientPermissions = (...permissionsResolvable: PermissionResolvable[]): MethodDecorator => {\n\tconst resolved = new PermissionsBitField(permissionsResolvable);\n\tconst resolvedIncludesServerPermissions = Boolean(resolved.bitfield & DMAvailablePermissions.bitfield);\n\n\treturn createFunctionPrecondition((context: Message | BaseInteraction) => {\n\t\tconst { channel } = context;\n\t\tconst member = context.guild?.members.me;\n\n\t\tif (resolvedIncludesServerPermissions && isDMChannel(channel)) {\n\t\t\tthrow new UserError({\n\t\t\t\tidentifier: DecoratorIdentifiers.RequiresClientPermissionsGuildOnly,\n\t\t\t\tmessage: 'Sorry, but that command can only be used in a server because I do not have sufficient permissions in DMs'\n\t\t\t});\n\t\t}\n\n\t\tif (isGuildBasedChannel(channel) && !isNullish(member)) {\n\t\t\tconst missingPermissions = channel.permissionsFor(member).missing(resolved);\n\n\t\t\tif (missingPermissions.length) {\n\t\t\t\tthrow new UserError({\n\t\t\t\t\tidentifier: DecoratorIdentifiers.RequiresClientPermissionsMissingPermissions,\n\t\t\t\t\tmessage: `Sorry, but I am not allowed to do that. I am missing the permissions: ${missingPermissions}`,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tmissing: missingPermissions\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t});\n};\n\n/**\n * Allows you to set permissions required for individual methods. This is particularly useful for subcommands that require specific permissions.\n * @remark This decorator applies to the user of the command. For setting permissions required for the client see {@link RequiresClientPermissions}\n * @remark This decorator makes the decorated function asynchronous, so any result should be `await`ed.\n * @param permissionsResolvable Permissions that the method should have.\n * @example\n * ```typescript\n * import { ApplyOptions, RequiresUserPermissions } from '@sapphire/decorators';\n * import { Subcommand } from '@sapphire/plugin-subcommands';\n * import type { Message } from 'discord.js';\n *\n * (at)ApplyOptions<Subcommand.Options>({\n * \taliases: ['cws'],\n * \tdescription: 'A basic command with some subcommands',\n * \tsubCommands: ['add', 'remove', 'reset', { input: 'show', default: true }]\n * })\n * export default class extends Subcommand {\n * // Anyone should be able to view the result, but not modify\n * \tpublic async show(message: Message) {\n * \t\treturn message.channel.send('Showing!');\n * \t}\n *\n * \t(at)RequiresUserPermissions('BAN_MEMBERS') // This subcommand requires the user of the command to be able to ban members.\n * \tpublic async add(message: Message) {\n * \t\treturn message.channel.send('Adding!');\n * \t}\n *\n * \t(at)RequiresUserPermissions('BAN_MEMBERS') // This subcommand requires the user of the command to be able to ban members.\n * \tpublic async remove(message: Message) {\n * \t\treturn message.channel.send('Removing!');\n * \t}\n *\n * \t(at)RequiresUserPermissions('BAN_MEMBERS') // This subcommand requires the user of the command to be able to ban members.\n * \tpublic async reset(message: Message) {\n * \t\treturn message.channel.send('Resetting!');\n * \t}\n * }\n * ```\n */\nexport const RequiresUserPermissions = (...permissionsResolvable: PermissionResolvable[]): MethodDecorator => {\n\tconst resolved = new PermissionsBitField(permissionsResolvable);\n\tconst resolvedIncludesServerPermissions = Boolean(resolved.bitfield & DMAvailableUserPermissions.bitfield);\n\n\treturn createFunctionPrecondition((context: Message | BaseInteraction) => {\n\t\tconst { channel } = context;\n\t\tconst member = context.guild?.members.me;\n\n\t\tif (resolvedIncludesServerPermissions && isDMChannel(channel)) {\n\t\t\tthrow new UserError({\n\t\t\t\tidentifier: DecoratorIdentifiers.RequiresUserPermissionsGuildOnly,\n\t\t\t\tmessage: 'Sorry, but that command can only be used in a server because you do not have sufficient permissions in DMs'\n\t\t\t});\n\t\t}\n\n\t\tif (isGuildBasedChannel(channel) && !isNullish(member)) {\n\t\t\tconst missingPermissions = channel.permissionsFor(member).missing(resolved);\n\n\t\t\tif (missingPermissions.length) {\n\t\t\t\tthrow new UserError({\n\t\t\t\t\tidentifier: DecoratorIdentifiers.RequiresUserPermissionsMissingPermissions,\n\t\t\t\t\tmessage: `Sorry, but you are not allowed to do that. You are missing the permissions: ${missingPermissions}`,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tmissing: missingPermissions\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t});\n};\n\n/**\n * Requires the message to be run in a guild context, this decorator requires the first argument to be a {@link Message} or {@link BaseInteraction} instance which includes all interaction types\n * @since 1.0.0\n * @param fallback The fallback value passed to {@link createFunctionPrecondition}\n */\nexport function RequiresGuildContext(fallback: FunctionFallback = (): void => undefined): MethodDecorator {\n\treturn createFunctionPrecondition((context: Message | BaseInteraction) => context.guild !== null, fallback);\n}\n\n/**\n * Requires the message to be run in a dm context, this decorator requires the first argument to be a {@link Message} or {@link BaseInteraction} instance which includes all interaction types\n * @since 1.0.0\n * @param fallback The fallback value passed to {@link createFunctionPrecondition}\n */\nexport function RequiresDMContext(fallback: FunctionFallback = (): void => undefined): MethodDecorator {\n\treturn createFunctionPrecondition((context: Message | BaseInteraction) => context.guild === null, fallback);\n}\n","import { container, type Piece } from '@sapphire/framework';\nimport type { Container } from '@sapphire/pieces';\nimport type { Ctor } from '@sapphire/utilities';\nimport { createClassDecorator, createProxy } from './utils';\n\n/**\n * Decorator function that applies given options to any Sapphire piece\n * @param optionsOrFn The options or function that returns options to pass to the piece constructor\n * @example\n * ```typescript\n * import { ApplyOptions } from '@sapphire/decorators';\n * import { Command } from '@sapphire/framework';\n * import type { Message } from 'discord.js';\n *\n * @ApplyOptions<Command.Options>({\n * description: 'ping pong',\n * enabled: true\n * })\n * export class UserCommand extends Command {\n * public override async messageRun(message: Message) {\n * const msg = await message.channel.send('Ping?');\n *\n * return msg.edit(\n * `Pong! Client Latency ${Math.round(this.container.client.ws.ping)}ms. API Latency ${msg.createdTimestamp - message.createdTimestamp}ms.`\n * );\n * }\n * }\n * ```\n * @example\n * ```typescript\n * import { ApplyOptions } from '@sapphire/decorators';\n * import { Listener } from '@sapphire/framework';\n * import { GatewayDispatchEvents, GatewayMessageDeleteDispatch } from 'discord.js';\n *\n * @ApplyOptions<Listener.Options>(({ container }) => ({\n * description: 'Handle Raw Message Delete events',\n * emitter: container.client.ws,\n * event: GatewayDispatchEvents.MessageDelete\n * }))\n * export class UserListener extends Listener {\n * public override run(data: GatewayMessageDeleteDispatch['d']): void {\n * if (!data.guild_id) return;\n *\n * const guild = this.container.client.guilds.cache.get(data.guild_id);\n * if (!guild || !guild.channels.cache.has(data.channel_id)) return;\n *\n * // Do something with the data\n * }\n * }\n * ```\n */\nexport function ApplyOptions<T extends Piece.Options>(optionsOrFn: T | ((parameters: ApplyOptionsCallbackParameters) => T)): ClassDecorator {\n\treturn createClassDecorator((target: Ctor<ConstructorParameters<typeof Piece>, Piece>) =>\n\t\tcreateProxy(target, {\n\t\t\tconstruct: (ctor, [context, baseOptions = {}]: [Piece.LoaderContext, Piece.Options]) =>\n\t\t\t\tnew ctor(context, {\n\t\t\t\t\t...baseOptions,\n\t\t\t\t\t...(typeof optionsOrFn === 'function' ? optionsOrFn({ container, context }) : optionsOrFn)\n\t\t\t\t})\n\t\t})\n\t);\n}\n\nexport interface ApplyOptionsCallbackParameters {\n\tcontainer: Container;\n\tcontext: Piece.LoaderContext;\n}\n"]}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -15,7 +15,7 @@ function createClassDecorator(fn) {
|
|
|
15
15
|
return fn;
|
|
16
16
|
}
|
|
17
17
|
__name(createClassDecorator, "createClassDecorator");
|
|
18
|
-
function createFunctionPrecondition(precondition, fallback = () =>
|
|
18
|
+
function createFunctionPrecondition(precondition, fallback = () => undefined) {
|
|
19
19
|
return createMethodDecorator((_target, _propertyKey, descriptor) => {
|
|
20
20
|
const method = descriptor.value;
|
|
21
21
|
if (!method) throw new Error("Function preconditions require a [[value]].");
|
|
@@ -147,11 +147,11 @@ var RequiresUserPermissions = /* @__PURE__ */ __name((...permissionsResolvable)
|
|
|
147
147
|
return true;
|
|
148
148
|
});
|
|
149
149
|
}, "RequiresUserPermissions");
|
|
150
|
-
function RequiresGuildContext(fallback = () =>
|
|
150
|
+
function RequiresGuildContext(fallback = () => undefined) {
|
|
151
151
|
return createFunctionPrecondition((context) => context.guild !== null, fallback);
|
|
152
152
|
}
|
|
153
153
|
__name(RequiresGuildContext, "RequiresGuildContext");
|
|
154
|
-
function RequiresDMContext(fallback = () =>
|
|
154
|
+
function RequiresDMContext(fallback = () => undefined) {
|
|
155
155
|
return createFunctionPrecondition((context) => context.guild === null, fallback);
|
|
156
156
|
}
|
|
157
157
|
__name(RequiresDMContext, "RequiresDMContext");
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils.ts","../../src/base-decorators.ts","../../src/djs-decorators.ts","../../src/piece-decorators.ts"],"names":["target","DecoratorIdentifiers"],"mappings":";;;;;;;;;AAiCO,SAAS,sBAAsB,EAAsC,EAAA;AAC3E,EAAO,OAAA,EAAA;AACR;AAFgB,MAAA,CAAA,qBAAA,EAAA,uBAAA,CAAA;AAST,SAAS,qBAA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AI,SAAU,CAAA;AAAA,UACnB,UAAY,EAAA,2CAAA;AAAA,UACZ,OAAA,EAAS,+EAA+E,kBAAkB,CAAA,CAAA;AAAA,UAC1G,OAAS,EAAA;AAAA,YACR,OAAS,EAAA;AAAA;AACV,SACA,CAAA;AAAA;AACF;AAGD,IAAO,OAAA,IAAA;AAAA,GACP,CAAA;AACF,CA/BuC,EAAA,yBAAA;AAsChC,SAAS,oBAAA,CAAqB,QAA6B,GAAA,MAAY,KAA4B,CAAA,EAAA;AACzG,EAAA,OAAO,2BAA2B,CAAC,OAAA,KAAuC,OAAQ,CAAA,KAAA,KAAU,MAAM,QAAQ,CAAA;AAC3G;AAFgB,MAAA,CAAA,oBAAA,EAAA,sBAAA,CAAA;AAST,SAAS,iBAAA,CAAkB,QAA6B,GAAA,MAAY,KAA4B,CAAA,EAAA;AACtG,EAAA,OAAO,2BAA2B,CAAC,OAAA,KAAuC,OAAQ,CAAA,KAAA,KAAU,MAAM,QAAQ,CAAA;AAC3G;AAFgB,MAAA,CAAA,iBAAA,EAAA,mBAAA,CAAA;ACnJT,SAAS,aAAsC,WAAsF,EAAA;AAC3I,EAAO,OAAA,oBAAA;AAAA,IAAqB,CAAC,MAC5B,KAAA,WAAA,CAAY,MAAQ,EAAA;AAAA,MACnB,SAAA,kBAAY,MAAA,CAAA,CAAA,IAAA,EAAM,CAAC,OAAA,EAAS,WAAc,GAAA,EAAE,CAAA,KAC3C,IAAI,IAAA,CAAK,OAAS,EAAA;AAAA,QACjB,GAAG,WAAA;AAAA,QACH,GAAI,OAAO,WAAgB,KAAA,UAAA,GAAa,YAAY,EAAE,SAAA,EAAW,OAAQ,EAAC,CAAI,GAAA;AAAA,OAC9E,CAJS,EAAA,WAAA;AAAA,KAKX;AAAA,GACF;AACD;AAVgB,MAAA,CAAA,YAAA,EAAA,cAAA,CAAA","file":"index.mjs","sourcesContent":["/**\n * The function precondition interface.\n */\nexport interface FunctionPrecondition {\n\t/**\n\t * The arguments passed to the function or class' method.\n\t */\n\t(...args: any[]): boolean | Promise<boolean>;\n}\n\n/**\n * The fallback interface, this is called when the function precondition returns or resolves with a falsy value.\n */\nexport interface FunctionFallback {\n\t/**\n\t * The arguments passed to the function or class' method.\n\t */\n\t(...args: any[]): unknown;\n}\n\n/**\n * Utility to make a method decorator with lighter syntax and inferred types.\n *\n * ```typescript\n * // Enumerable function\n *\tfunction enumerableMethod(value: boolean) {\n *\t\treturn createMethodDecorator((_target, _propertyKey, descriptor) => {\n *\t\t\tdescriptor.enumerable = value;\n *\t\t});\n *\t}\n * ```\n * @param fn The method to decorate\n */\nexport function createMethodDecorator(fn: MethodDecorator): MethodDecorator {\n\treturn fn;\n}\n\n/**\n * Utility to make a class decorator with lighter syntax and inferred types.\n * @param fn The class to decorate\n * @see {@link ApplyOptions}\n */\nexport function createClassDecorator<TFunction extends (...args: any[]) => void>(fn: TFunction): ClassDecorator {\n\treturn fn;\n}\n\n/**\n * Utility to make function preconditions.\n *\n * ```typescript\n * // No fallback (returns undefined)\n * function requireGuild(value: number) {\n * return createFunctionPrecondition((message: Message) =>\n * message.guild !== null\n * );\n * }\n *\n * // With fallback\n * function requireGuild(\n * value: number,\n * fallback: () => unknown = () => undefined\n * ) {\n * return createFunctionPrecondition(\n * (message: Message) => message.guild !== null,\n * fallback\n * );\n * }\n * ```\n * @since 1.0.0\n * @param precondition The function that defines whether or not the function should be run, returning the returned value from fallback\n * @param fallback The fallback value that defines what the method should return in case the precondition fails\n */\nexport function createFunctionPrecondition(precondition: FunctionPrecondition, fallback: FunctionFallback = (): void => undefined): MethodDecorator {\n\treturn createMethodDecorator((_target, _propertyKey, descriptor) => {\n\t\tconst method = descriptor.value;\n\t\tif (!method) throw new Error('Function preconditions require a [[value]].');\n\t\tif (typeof method !== 'function') throw new Error('Function preconditions can only be applied to functions.');\n\n\t\tdescriptor.value = async function descriptorValue(this: (...args: any[]) => any, ...args: any[]) {\n\t\t\tconst canRun = await precondition(...args);\n\t\t\treturn canRun ? method.call(this, ...args) : fallback.call(this, ...args);\n\t\t} as unknown as undefined;\n\t});\n}\n\n/**\n * Creates a new proxy to efficiently add properties to class without creating subclasses\n * @param target The constructor of the class to modify\n * @param handler The handler function to modify the constructor behavior for the target\n * @hidden\n */\nexport function createProxy<T extends object>(target: T, handler: Omit<ProxyHandler<T>, 'get'>): T {\n\treturn new Proxy(target, {\n\t\t...handler,\n\t\tget: (target, property) => {\n\t\t\tconst value = Reflect.get(target, property);\n\t\t\treturn typeof value === 'function' ? (...args: readonly unknown[]) => value.apply(target, args) : value;\n\t\t}\n\t});\n}\n","import { createMethodDecorator } from './utils';\n\n/**\n * Decorator that sets the enumerable property of a class field to the desired value.\n * @param value Whether the property should be enumerable or not\n */\nexport function Enumerable(value: boolean) {\n\treturn (target: object, key: string) => {\n\t\tReflect.defineProperty(target, key, {\n\t\t\tenumerable: value,\n\t\t\tset(this: unknown, val: unknown) {\n\t\t\t\tReflect.defineProperty(this as object, key, {\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t\tenumerable: value,\n\t\t\t\t\tvalue: val,\n\t\t\t\t\twritable: true\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t};\n}\n\n/**\n * Decorator that sets the enumerable property of a class method to the desired value.\n * @param value Whether the method should be enumerable or not\n */\nexport function EnumerableMethod(value: boolean) {\n\treturn createMethodDecorator((_target, _propertyKey, descriptor) => {\n\t\tdescriptor.enumerable = value;\n\t});\n}\n","import { isDMChannel, isGuildBasedChannel } from '@sapphire/discord.js-utilities';\nimport { UserError } from '@sapphire/framework';\nimport { isNullish } from '@sapphire/utilities';\nimport { PermissionFlagsBits, PermissionsBitField, type BaseInteraction, type Message, type PermissionResolvable } from 'discord.js';\nimport { createFunctionPrecondition, type FunctionFallback } from './utils';\n\nexport enum DecoratorIdentifiers {\n\tRequiresClientPermissionsGuildOnly = 'requiresClientPermissionsGuildOnly',\n\tRequiresClientPermissionsMissingPermissions = 'requiresClientPermissionsMissingPermissions',\n\tRequiresUserPermissionsGuildOnly = 'requiresUserPermissionsGuildOnly',\n\tRequiresUserPermissionsMissingPermissions = 'requiresUserPermissionsMissingPermissions'\n}\n\nconst DMAvailablePermissions = new PermissionsBitField(\n\t~new PermissionsBitField([\n\t\t//\n\t\tPermissionFlagsBits.AddReactions,\n\t\tPermissionFlagsBits.AttachFiles,\n\t\tPermissionFlagsBits.EmbedLinks,\n\t\tPermissionFlagsBits.ReadMessageHistory,\n\t\tPermissionFlagsBits.SendMessages,\n\t\tPermissionFlagsBits.UseExternalEmojis,\n\t\tPermissionFlagsBits.ViewChannel\n\t]).bitfield & PermissionsBitField.All\n);\n\nconst DMAvailableUserPermissions = new PermissionsBitField(\n\t~new PermissionsBitField([\n\t\tPermissionFlagsBits.AddReactions,\n\t\tPermissionFlagsBits.AttachFiles,\n\t\tPermissionFlagsBits.EmbedLinks,\n\t\tPermissionFlagsBits.ReadMessageHistory,\n\t\tPermissionFlagsBits.SendMessages,\n\t\tPermissionFlagsBits.UseExternalEmojis,\n\t\tPermissionFlagsBits.ViewChannel,\n\t\tPermissionFlagsBits.UseExternalStickers,\n\t\tPermissionFlagsBits.MentionEveryone\n\t]).bitfield & PermissionsBitField.All\n);\n\n/**\n * Allows you to set permissions required for individual methods. This is particularly useful for subcommands that require specific permissions.\n * @remark This decorator applies to the client that is to execute the command. For setting permissions required user of the command see {@link RequiresUserPermissions}\n * @remark This decorator makes the decorated function asynchronous, so any result should be `await`ed.\n * @param permissionsResolvable Permissions that the method should have.\n * @example\n * ```typescript\n * import { ApplyOptions, RequiresClientPermissions } from '@sapphire/decorators';\n * import { Subcommand } from '@sapphire/plugin-subcommands';\n * import type { Message } from 'discord.js';\n *\n * (at)ApplyOptions<Subcommand.Options>({\n * \taliases: ['cws'],\n * \tdescription: 'A basic command with some subcommands',\n * \tsubCommands: ['add', 'remove', 'reset', { input: 'show', default: true }]\n * })\n * export default class extends Subcommand {\n * // Anyone should be able to view the result, but not modify\n * \tpublic async show(message: Message) {\n * \t\treturn message.channel.send('Showing!');\n * \t}\n *\n * \t(at)RequiresClientPermissions('BAN_MEMBERS') // This subcommand requires the client to be able to ban members.\n * \tpublic async add(message: Message) {\n * \t\treturn message.channel.send('Adding!');\n * \t}\n *\n * \t(at)RequiresClientPermissions('BAN_MEMBERS') // This subcommand requires the client to be able to ban members.\n * \tpublic async remove(message: Message) {\n * \t\treturn message.channel.send('Removing!');\n * \t}\n *\n * \t(at)RequiresClientPermissions('BAN_MEMBERS') // This subcommand requires the client to be able to ban members.\n * \tpublic async reset(message: Message) {\n * \t\treturn message.channel.send('Resetting!');\n * \t}\n * }\n * ```\n */\nexport const RequiresClientPermissions = (...permissionsResolvable: PermissionResolvable[]): MethodDecorator => {\n\tconst resolved = new PermissionsBitField(permissionsResolvable);\n\tconst resolvedIncludesServerPermissions = Boolean(resolved.bitfield & DMAvailablePermissions.bitfield);\n\n\treturn createFunctionPrecondition((context: Message | BaseInteraction) => {\n\t\tconst { channel } = context;\n\t\tconst member = context.guild?.members.me;\n\n\t\tif (resolvedIncludesServerPermissions && isDMChannel(channel)) {\n\t\t\tthrow new UserError({\n\t\t\t\tidentifier: DecoratorIdentifiers.RequiresClientPermissionsGuildOnly,\n\t\t\t\tmessage: 'Sorry, but that command can only be used in a server because I do not have sufficient permissions in DMs'\n\t\t\t});\n\t\t}\n\n\t\tif (isGuildBasedChannel(channel) && !isNullish(member)) {\n\t\t\tconst missingPermissions = channel.permissionsFor(member).missing(resolved);\n\n\t\t\tif (missingPermissions.length) {\n\t\t\t\tthrow new UserError({\n\t\t\t\t\tidentifier: DecoratorIdentifiers.RequiresClientPermissionsMissingPermissions,\n\t\t\t\t\tmessage: `Sorry, but I am not allowed to do that. I am missing the permissions: ${missingPermissions}`,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tmissing: missingPermissions\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t});\n};\n\n/**\n * Allows you to set permissions required for individual methods. This is particularly useful for subcommands that require specific permissions.\n * @remark This decorator applies to the user of the command. For setting permissions required for the client see {@link RequiresClientPermissions}\n * @remark This decorator makes the decorated function asynchronous, so any result should be `await`ed.\n * @param permissionsResolvable Permissions that the method should have.\n * @example\n * ```typescript\n * import { ApplyOptions, RequiresUserPermissions } from '@sapphire/decorators';\n * import { Subcommand } from '@sapphire/plugin-subcommands';\n * import type { Message } from 'discord.js';\n *\n * (at)ApplyOptions<Subcommand.Options>({\n * \taliases: ['cws'],\n * \tdescription: 'A basic command with some subcommands',\n * \tsubCommands: ['add', 'remove', 'reset', { input: 'show', default: true }]\n * })\n * export default class extends Subcommand {\n * // Anyone should be able to view the result, but not modify\n * \tpublic async show(message: Message) {\n * \t\treturn message.channel.send('Showing!');\n * \t}\n *\n * \t(at)RequiresUserPermissions('BAN_MEMBERS') // This subcommand requires the user of the command to be able to ban members.\n * \tpublic async add(message: Message) {\n * \t\treturn message.channel.send('Adding!');\n * \t}\n *\n * \t(at)RequiresUserPermissions('BAN_MEMBERS') // This subcommand requires the user of the command to be able to ban members.\n * \tpublic async remove(message: Message) {\n * \t\treturn message.channel.send('Removing!');\n * \t}\n *\n * \t(at)RequiresUserPermissions('BAN_MEMBERS') // This subcommand requires the user of the command to be able to ban members.\n * \tpublic async reset(message: Message) {\n * \t\treturn message.channel.send('Resetting!');\n * \t}\n * }\n * ```\n */\nexport const RequiresUserPermissions = (...permissionsResolvable: PermissionResolvable[]): MethodDecorator => {\n\tconst resolved = new PermissionsBitField(permissionsResolvable);\n\tconst resolvedIncludesServerPermissions = Boolean(resolved.bitfield & DMAvailableUserPermissions.bitfield);\n\n\treturn createFunctionPrecondition((context: Message | BaseInteraction) => {\n\t\tconst { channel } = context;\n\t\tconst member = context.guild?.members.me;\n\n\t\tif (resolvedIncludesServerPermissions && isDMChannel(channel)) {\n\t\t\tthrow new UserError({\n\t\t\t\tidentifier: DecoratorIdentifiers.RequiresUserPermissionsGuildOnly,\n\t\t\t\tmessage: 'Sorry, but that command can only be used in a server because you do not have sufficient permissions in DMs'\n\t\t\t});\n\t\t}\n\n\t\tif (isGuildBasedChannel(channel) && !isNullish(member)) {\n\t\t\tconst missingPermissions = channel.permissionsFor(member).missing(resolved);\n\n\t\t\tif (missingPermissions.length) {\n\t\t\t\tthrow new UserError({\n\t\t\t\t\tidentifier: DecoratorIdentifiers.RequiresUserPermissionsMissingPermissions,\n\t\t\t\t\tmessage: `Sorry, but you are not allowed to do that. You are missing the permissions: ${missingPermissions}`,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tmissing: missingPermissions\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t});\n};\n\n/**\n * Requires the message to be run in a guild context, this decorator requires the first argument to be a {@link Message} or {@link BaseInteraction} instance which includes all interaction types\n * @since 1.0.0\n * @param fallback The fallback value passed to {@link createFunctionPrecondition}\n */\nexport function RequiresGuildContext(fallback: FunctionFallback = (): void => undefined): MethodDecorator {\n\treturn createFunctionPrecondition((context: Message | BaseInteraction) => context.guild !== null, fallback);\n}\n\n/**\n * Requires the message to be run in a dm context, this decorator requires the first argument to be a {@link Message} or {@link BaseInteraction} instance which includes all interaction types\n * @since 1.0.0\n * @param fallback The fallback value passed to {@link createFunctionPrecondition}\n */\nexport function RequiresDMContext(fallback: FunctionFallback = (): void => undefined): MethodDecorator {\n\treturn createFunctionPrecondition((context: Message | BaseInteraction) => context.guild === null, fallback);\n}\n","import { container, type Piece } from '@sapphire/framework';\nimport type { Container } from '@sapphire/pieces';\nimport type { Ctor } from '@sapphire/utilities';\nimport { createClassDecorator, createProxy } from './utils';\n\n/**\n * Decorator function that applies given options to any Sapphire piece\n * @param optionsOrFn The options or function that returns options to pass to the piece constructor\n * @example\n * ```typescript\n * import { ApplyOptions } from '@sapphire/decorators';\n * import { Command } from '@sapphire/framework';\n * import type { Message } from 'discord.js';\n *\n * @ApplyOptions<Command.Options>({\n * description: 'ping pong',\n * enabled: true\n * })\n * export class UserCommand extends Command {\n * public override async messageRun(message: Message) {\n * const msg = await message.channel.send('Ping?');\n *\n * return msg.edit(\n * `Pong! Client Latency ${Math.round(this.container.client.ws.ping)}ms. API Latency ${msg.createdTimestamp - message.createdTimestamp}ms.`\n * );\n * }\n * }\n * ```\n * @example\n * ```typescript\n * import { ApplyOptions } from '@sapphire/decorators';\n * import { Listener } from '@sapphire/framework';\n * import { GatewayDispatchEvents, GatewayMessageDeleteDispatch } from 'discord.js';\n *\n * @ApplyOptions<Listener.Options>(({ container }) => ({\n * description: 'Handle Raw Message Delete events',\n * emitter: container.client.ws,\n * event: GatewayDispatchEvents.MessageDelete\n * }))\n * export class UserListener extends Listener {\n * public override run(data: GatewayMessageDeleteDispatch['d']): void {\n * if (!data.guild_id) return;\n *\n * const guild = this.container.client.guilds.cache.get(data.guild_id);\n * if (!guild || !guild.channels.cache.has(data.channel_id)) return;\n *\n * // Do something with the data\n * }\n * }\n * ```\n */\nexport function ApplyOptions<T extends Piece.Options>(optionsOrFn: T | ((parameters: ApplyOptionsCallbackParameters) => T)): ClassDecorator {\n\treturn createClassDecorator((target: Ctor<ConstructorParameters<typeof Piece>, Piece>) =>\n\t\tcreateProxy(target, {\n\t\t\tconstruct: (ctor, [context, baseOptions = {}]: [Piece.LoaderContext, Piece.Options]) =>\n\t\t\t\tnew ctor(context, {\n\t\t\t\t\t...baseOptions,\n\t\t\t\t\t...(typeof optionsOrFn === 'function' ? optionsOrFn({ container, context }) : optionsOrFn)\n\t\t\t\t})\n\t\t})\n\t);\n}\n\nexport interface ApplyOptionsCallbackParameters {\n\tcontainer: Container;\n\tcontext: Piece.LoaderContext;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils.ts","../../src/base-decorators.ts","../../src/djs-decorators.ts","../../src/piece-decorators.ts"],"names":["target","DecoratorIdentifiers"],"mappings":";;;;;;;;;AAiCO,SAAS,sBAAsB,EAAsC,EAAA;AAC3E,EAAO,OAAA,EAAA;AACR;AAFgB,MAAA,CAAA,qBAAA,EAAA,uBAAA,CAAA;AAST,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M,IAAI,SAAU,CAAA;AAAA,UACnB,UAAY,EAAA,2CAAA;AAAA,UACZ,OAAA,EAAS,+EAA+E,kBAAkB,CAAA,CAAA;AAAA,UAC1G,OAAS,EAAA;AAAA,YACR,OAAS,EAAA;AAAA;AACV,SACA,CAAA;AAAA;AACF;AAGD,IAAO,OAAA,IAAA;AAAA,GACP,CAAA;AACF,CA/BuC,EAAA,yBAAA;AAsChC,SAAS,oBAAA,CAAqB,QAA6B,GAAA,MAAY,SAA4B,EAAA;AACzG,EAAA,OAAO,2BAA2B,CAAC,OAAA,KAAuC,OAAQ,CAAA,KAAA,KAAU,MAAM,QAAQ,CAAA;AAC3G;AAFgB,MAAA,CAAA,oBAAA,EAAA,sBAAA,CAAA;AAST,SAAS,iBAAA,CAAkB,QAA6B,GAAA,MAAY,SAA4B,EAAA;AACtG,EAAA,OAAO,2BAA2B,CAAC,OAAA,KAAuC,OAAQ,CAAA,KAAA,KAAU,MAAM,QAAQ,CAAA;AAC3G;AAFgB,MAAA,CAAA,iBAAA,EAAA,mBAAA,CAAA;ACnJT,SAAS,aAAsC,WAAsF,EAAA;AAC3I,EAAO,OAAA,oBAAA;AAAA,IAAqB,CAAC,MAC5B,KAAA,WAAA,CAAY,MAAQ,EAAA;AAAA,MACnB,SAAA,kBAAY,MAAA,CAAA,CAAA,IAAA,EAAM,CAAC,OAAA,EAAS,WAAc,GAAA,EAAE,CAAA,KAC3C,IAAI,IAAA,CAAK,OAAS,EAAA;AAAA,QACjB,GAAG,WAAA;AAAA,QACH,GAAI,OAAO,WAAgB,KAAA,UAAA,GAAa,YAAY,EAAE,SAAA,EAAW,OAAQ,EAAC,CAAI,GAAA;AAAA,OAC9E,CAJS,EAAA,WAAA;AAAA,KAKX;AAAA,GACF;AACD;AAVgB,MAAA,CAAA,YAAA,EAAA,cAAA,CAAA","file":"index.mjs","sourcesContent":["/**\n * The function precondition interface.\n */\nexport interface FunctionPrecondition {\n\t/**\n\t * The arguments passed to the function or class' method.\n\t */\n\t(...args: any[]): boolean | Promise<boolean>;\n}\n\n/**\n * The fallback interface, this is called when the function precondition returns or resolves with a falsy value.\n */\nexport interface FunctionFallback {\n\t/**\n\t * The arguments passed to the function or class' method.\n\t */\n\t(...args: any[]): unknown;\n}\n\n/**\n * Utility to make a method decorator with lighter syntax and inferred types.\n *\n * ```typescript\n * // Enumerable function\n *\tfunction enumerableMethod(value: boolean) {\n *\t\treturn createMethodDecorator((_target, _propertyKey, descriptor) => {\n *\t\t\tdescriptor.enumerable = value;\n *\t\t});\n *\t}\n * ```\n * @param fn The method to decorate\n */\nexport function createMethodDecorator(fn: MethodDecorator): MethodDecorator {\n\treturn fn;\n}\n\n/**\n * Utility to make a class decorator with lighter syntax and inferred types.\n * @param fn The class to decorate\n * @see {@link ApplyOptions}\n */\nexport function createClassDecorator<TFunction extends (...args: any[]) => void>(fn: TFunction): ClassDecorator {\n\treturn fn;\n}\n\n/**\n * Utility to make function preconditions.\n *\n * ```typescript\n * // No fallback (returns undefined)\n * function requireGuild(value: number) {\n * return createFunctionPrecondition((message: Message) =>\n * message.guild !== null\n * );\n * }\n *\n * // With fallback\n * function requireGuild(\n * value: number,\n * fallback: () => unknown = () => undefined\n * ) {\n * return createFunctionPrecondition(\n * (message: Message) => message.guild !== null,\n * fallback\n * );\n * }\n * ```\n * @since 1.0.0\n * @param precondition The function that defines whether or not the function should be run, returning the returned value from fallback\n * @param fallback The fallback value that defines what the method should return in case the precondition fails\n */\nexport function createFunctionPrecondition(precondition: FunctionPrecondition, fallback: FunctionFallback = (): void => undefined): MethodDecorator {\n\treturn createMethodDecorator((_target, _propertyKey, descriptor) => {\n\t\tconst method = descriptor.value;\n\t\tif (!method) throw new Error('Function preconditions require a [[value]].');\n\t\tif (typeof method !== 'function') throw new Error('Function preconditions can only be applied to functions.');\n\n\t\tdescriptor.value = async function descriptorValue(this: (...args: any[]) => any, ...args: any[]) {\n\t\t\tconst canRun = await precondition(...args);\n\t\t\treturn canRun ? method.call(this, ...args) : fallback.call(this, ...args);\n\t\t} as unknown as undefined;\n\t});\n}\n\n/**\n * Creates a new proxy to efficiently add properties to class without creating subclasses\n * @param target The constructor of the class to modify\n * @param handler The handler function to modify the constructor behavior for the target\n * @hidden\n */\nexport function createProxy<T extends object>(target: T, handler: Omit<ProxyHandler<T>, 'get'>): T {\n\treturn new Proxy(target, {\n\t\t...handler,\n\t\tget: (target, property) => {\n\t\t\tconst value = Reflect.get(target, property);\n\t\t\treturn typeof value === 'function' ? (...args: readonly unknown[]) => value.apply(target, args) : value;\n\t\t}\n\t});\n}\n","import { createMethodDecorator } from './utils';\n\n/**\n * Decorator that sets the enumerable property of a class field to the desired value.\n * @param value Whether the property should be enumerable or not\n */\nexport function Enumerable(value: boolean) {\n\treturn (target: object, key: string) => {\n\t\tReflect.defineProperty(target, key, {\n\t\t\tenumerable: value,\n\t\t\tset(this: unknown, val: unknown) {\n\t\t\t\tReflect.defineProperty(this as object, key, {\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t\tenumerable: value,\n\t\t\t\t\tvalue: val,\n\t\t\t\t\twritable: true\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t};\n}\n\n/**\n * Decorator that sets the enumerable property of a class method to the desired value.\n * @param value Whether the method should be enumerable or not\n */\nexport function EnumerableMethod(value: boolean) {\n\treturn createMethodDecorator((_target, _propertyKey, descriptor) => {\n\t\tdescriptor.enumerable = value;\n\t});\n}\n","import { isDMChannel, isGuildBasedChannel } from '@sapphire/discord.js-utilities';\nimport { UserError } from '@sapphire/framework';\nimport { isNullish } from '@sapphire/utilities';\nimport { PermissionFlagsBits, PermissionsBitField, type BaseInteraction, type Message, type PermissionResolvable } from 'discord.js';\nimport { createFunctionPrecondition, type FunctionFallback } from './utils';\n\nexport enum DecoratorIdentifiers {\n\tRequiresClientPermissionsGuildOnly = 'requiresClientPermissionsGuildOnly',\n\tRequiresClientPermissionsMissingPermissions = 'requiresClientPermissionsMissingPermissions',\n\tRequiresUserPermissionsGuildOnly = 'requiresUserPermissionsGuildOnly',\n\tRequiresUserPermissionsMissingPermissions = 'requiresUserPermissionsMissingPermissions'\n}\n\nconst DMAvailablePermissions = new PermissionsBitField(\n\t~new PermissionsBitField([\n\t\t//\n\t\tPermissionFlagsBits.AddReactions,\n\t\tPermissionFlagsBits.AttachFiles,\n\t\tPermissionFlagsBits.EmbedLinks,\n\t\tPermissionFlagsBits.ReadMessageHistory,\n\t\tPermissionFlagsBits.SendMessages,\n\t\tPermissionFlagsBits.UseExternalEmojis,\n\t\tPermissionFlagsBits.ViewChannel\n\t]).bitfield & PermissionsBitField.All\n);\n\nconst DMAvailableUserPermissions = new PermissionsBitField(\n\t~new PermissionsBitField([\n\t\tPermissionFlagsBits.AddReactions,\n\t\tPermissionFlagsBits.AttachFiles,\n\t\tPermissionFlagsBits.EmbedLinks,\n\t\tPermissionFlagsBits.ReadMessageHistory,\n\t\tPermissionFlagsBits.SendMessages,\n\t\tPermissionFlagsBits.UseExternalEmojis,\n\t\tPermissionFlagsBits.ViewChannel,\n\t\tPermissionFlagsBits.UseExternalStickers,\n\t\tPermissionFlagsBits.MentionEveryone\n\t]).bitfield & PermissionsBitField.All\n);\n\n/**\n * Allows you to set permissions required for individual methods. This is particularly useful for subcommands that require specific permissions.\n * @remark This decorator applies to the client that is to execute the command. For setting permissions required user of the command see {@link RequiresUserPermissions}\n * @remark This decorator makes the decorated function asynchronous, so any result should be `await`ed.\n * @param permissionsResolvable Permissions that the method should have.\n * @example\n * ```typescript\n * import { ApplyOptions, RequiresClientPermissions } from '@sapphire/decorators';\n * import { Subcommand } from '@sapphire/plugin-subcommands';\n * import type { Message } from 'discord.js';\n *\n * (at)ApplyOptions<Subcommand.Options>({\n * \taliases: ['cws'],\n * \tdescription: 'A basic command with some subcommands',\n * \tsubCommands: ['add', 'remove', 'reset', { input: 'show', default: true }]\n * })\n * export default class extends Subcommand {\n * // Anyone should be able to view the result, but not modify\n * \tpublic async show(message: Message) {\n * \t\treturn message.channel.send('Showing!');\n * \t}\n *\n * \t(at)RequiresClientPermissions('BAN_MEMBERS') // This subcommand requires the client to be able to ban members.\n * \tpublic async add(message: Message) {\n * \t\treturn message.channel.send('Adding!');\n * \t}\n *\n * \t(at)RequiresClientPermissions('BAN_MEMBERS') // This subcommand requires the client to be able to ban members.\n * \tpublic async remove(message: Message) {\n * \t\treturn message.channel.send('Removing!');\n * \t}\n *\n * \t(at)RequiresClientPermissions('BAN_MEMBERS') // This subcommand requires the client to be able to ban members.\n * \tpublic async reset(message: Message) {\n * \t\treturn message.channel.send('Resetting!');\n * \t}\n * }\n * ```\n */\nexport const RequiresClientPermissions = (...permissionsResolvable: PermissionResolvable[]): MethodDecorator => {\n\tconst resolved = new PermissionsBitField(permissionsResolvable);\n\tconst resolvedIncludesServerPermissions = Boolean(resolved.bitfield & DMAvailablePermissions.bitfield);\n\n\treturn createFunctionPrecondition((context: Message | BaseInteraction) => {\n\t\tconst { channel } = context;\n\t\tconst member = context.guild?.members.me;\n\n\t\tif (resolvedIncludesServerPermissions && isDMChannel(channel)) {\n\t\t\tthrow new UserError({\n\t\t\t\tidentifier: DecoratorIdentifiers.RequiresClientPermissionsGuildOnly,\n\t\t\t\tmessage: 'Sorry, but that command can only be used in a server because I do not have sufficient permissions in DMs'\n\t\t\t});\n\t\t}\n\n\t\tif (isGuildBasedChannel(channel) && !isNullish(member)) {\n\t\t\tconst missingPermissions = channel.permissionsFor(member).missing(resolved);\n\n\t\t\tif (missingPermissions.length) {\n\t\t\t\tthrow new UserError({\n\t\t\t\t\tidentifier: DecoratorIdentifiers.RequiresClientPermissionsMissingPermissions,\n\t\t\t\t\tmessage: `Sorry, but I am not allowed to do that. I am missing the permissions: ${missingPermissions}`,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tmissing: missingPermissions\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t});\n};\n\n/**\n * Allows you to set permissions required for individual methods. This is particularly useful for subcommands that require specific permissions.\n * @remark This decorator applies to the user of the command. For setting permissions required for the client see {@link RequiresClientPermissions}\n * @remark This decorator makes the decorated function asynchronous, so any result should be `await`ed.\n * @param permissionsResolvable Permissions that the method should have.\n * @example\n * ```typescript\n * import { ApplyOptions, RequiresUserPermissions } from '@sapphire/decorators';\n * import { Subcommand } from '@sapphire/plugin-subcommands';\n * import type { Message } from 'discord.js';\n *\n * (at)ApplyOptions<Subcommand.Options>({\n * \taliases: ['cws'],\n * \tdescription: 'A basic command with some subcommands',\n * \tsubCommands: ['add', 'remove', 'reset', { input: 'show', default: true }]\n * })\n * export default class extends Subcommand {\n * // Anyone should be able to view the result, but not modify\n * \tpublic async show(message: Message) {\n * \t\treturn message.channel.send('Showing!');\n * \t}\n *\n * \t(at)RequiresUserPermissions('BAN_MEMBERS') // This subcommand requires the user of the command to be able to ban members.\n * \tpublic async add(message: Message) {\n * \t\treturn message.channel.send('Adding!');\n * \t}\n *\n * \t(at)RequiresUserPermissions('BAN_MEMBERS') // This subcommand requires the user of the command to be able to ban members.\n * \tpublic async remove(message: Message) {\n * \t\treturn message.channel.send('Removing!');\n * \t}\n *\n * \t(at)RequiresUserPermissions('BAN_MEMBERS') // This subcommand requires the user of the command to be able to ban members.\n * \tpublic async reset(message: Message) {\n * \t\treturn message.channel.send('Resetting!');\n * \t}\n * }\n * ```\n */\nexport const RequiresUserPermissions = (...permissionsResolvable: PermissionResolvable[]): MethodDecorator => {\n\tconst resolved = new PermissionsBitField(permissionsResolvable);\n\tconst resolvedIncludesServerPermissions = Boolean(resolved.bitfield & DMAvailableUserPermissions.bitfield);\n\n\treturn createFunctionPrecondition((context: Message | BaseInteraction) => {\n\t\tconst { channel } = context;\n\t\tconst member = context.guild?.members.me;\n\n\t\tif (resolvedIncludesServerPermissions && isDMChannel(channel)) {\n\t\t\tthrow new UserError({\n\t\t\t\tidentifier: DecoratorIdentifiers.RequiresUserPermissionsGuildOnly,\n\t\t\t\tmessage: 'Sorry, but that command can only be used in a server because you do not have sufficient permissions in DMs'\n\t\t\t});\n\t\t}\n\n\t\tif (isGuildBasedChannel(channel) && !isNullish(member)) {\n\t\t\tconst missingPermissions = channel.permissionsFor(member).missing(resolved);\n\n\t\t\tif (missingPermissions.length) {\n\t\t\t\tthrow new UserError({\n\t\t\t\t\tidentifier: DecoratorIdentifiers.RequiresUserPermissionsMissingPermissions,\n\t\t\t\t\tmessage: `Sorry, but you are not allowed to do that. You are missing the permissions: ${missingPermissions}`,\n\t\t\t\t\tcontext: {\n\t\t\t\t\t\tmissing: missingPermissions\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t});\n};\n\n/**\n * Requires the message to be run in a guild context, this decorator requires the first argument to be a {@link Message} or {@link BaseInteraction} instance which includes all interaction types\n * @since 1.0.0\n * @param fallback The fallback value passed to {@link createFunctionPrecondition}\n */\nexport function RequiresGuildContext(fallback: FunctionFallback = (): void => undefined): MethodDecorator {\n\treturn createFunctionPrecondition((context: Message | BaseInteraction) => context.guild !== null, fallback);\n}\n\n/**\n * Requires the message to be run in a dm context, this decorator requires the first argument to be a {@link Message} or {@link BaseInteraction} instance which includes all interaction types\n * @since 1.0.0\n * @param fallback The fallback value passed to {@link createFunctionPrecondition}\n */\nexport function RequiresDMContext(fallback: FunctionFallback = (): void => undefined): MethodDecorator {\n\treturn createFunctionPrecondition((context: Message | BaseInteraction) => context.guild === null, fallback);\n}\n","import { container, type Piece } from '@sapphire/framework';\nimport type { Container } from '@sapphire/pieces';\nimport type { Ctor } from '@sapphire/utilities';\nimport { createClassDecorator, createProxy } from './utils';\n\n/**\n * Decorator function that applies given options to any Sapphire piece\n * @param optionsOrFn The options or function that returns options to pass to the piece constructor\n * @example\n * ```typescript\n * import { ApplyOptions } from '@sapphire/decorators';\n * import { Command } from '@sapphire/framework';\n * import type { Message } from 'discord.js';\n *\n * @ApplyOptions<Command.Options>({\n * description: 'ping pong',\n * enabled: true\n * })\n * export class UserCommand extends Command {\n * public override async messageRun(message: Message) {\n * const msg = await message.channel.send('Ping?');\n *\n * return msg.edit(\n * `Pong! Client Latency ${Math.round(this.container.client.ws.ping)}ms. API Latency ${msg.createdTimestamp - message.createdTimestamp}ms.`\n * );\n * }\n * }\n * ```\n * @example\n * ```typescript\n * import { ApplyOptions } from '@sapphire/decorators';\n * import { Listener } from '@sapphire/framework';\n * import { GatewayDispatchEvents, GatewayMessageDeleteDispatch } from 'discord.js';\n *\n * @ApplyOptions<Listener.Options>(({ container }) => ({\n * description: 'Handle Raw Message Delete events',\n * emitter: container.client.ws,\n * event: GatewayDispatchEvents.MessageDelete\n * }))\n * export class UserListener extends Listener {\n * public override run(data: GatewayMessageDeleteDispatch['d']): void {\n * if (!data.guild_id) return;\n *\n * const guild = this.container.client.guilds.cache.get(data.guild_id);\n * if (!guild || !guild.channels.cache.has(data.channel_id)) return;\n *\n * // Do something with the data\n * }\n * }\n * ```\n */\nexport function ApplyOptions<T extends Piece.Options>(optionsOrFn: T | ((parameters: ApplyOptionsCallbackParameters) => T)): ClassDecorator {\n\treturn createClassDecorator((target: Ctor<ConstructorParameters<typeof Piece>, Piece>) =>\n\t\tcreateProxy(target, {\n\t\t\tconstruct: (ctor, [context, baseOptions = {}]: [Piece.LoaderContext, Piece.Options]) =>\n\t\t\t\tnew ctor(context, {\n\t\t\t\t\t...baseOptions,\n\t\t\t\t\t...(typeof optionsOrFn === 'function' ? optionsOrFn({ container, context }) : optionsOrFn)\n\t\t\t\t})\n\t\t})\n\t);\n}\n\nexport interface ApplyOptionsCallbackParameters {\n\tcontainer: Container;\n\tcontext: Piece.LoaderContext;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sapphire/decorators",
|
|
3
|
-
"version": "6.1.2-next.
|
|
3
|
+
"version": "6.1.2-next.5d7bdbbc",
|
|
4
4
|
"description": "Useful TypeScript decorators for Sapphire Framework Discord bots",
|
|
5
5
|
"author": "@sapphire",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,19 +34,19 @@
|
|
|
34
34
|
"tslib": "^2.8.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@favware/cliff-jumper": "^
|
|
38
|
-
"@sapphire/discord-utilities": "^3.4.
|
|
39
|
-
"@sapphire/discord.js-utilities": "^7.3.
|
|
37
|
+
"@favware/cliff-jumper": "^6.0.0",
|
|
38
|
+
"@sapphire/discord-utilities": "^3.4.4",
|
|
39
|
+
"@sapphire/discord.js-utilities": "^7.3.2",
|
|
40
40
|
"@sapphire/ratelimits": "^2.4.11",
|
|
41
41
|
"@sapphire/result": "^2.7.2",
|
|
42
42
|
"@sapphire/utilities": "^3.18.1",
|
|
43
|
-
"@vitest/coverage-v8": "^2.1.
|
|
43
|
+
"@vitest/coverage-v8": "^2.1.8",
|
|
44
44
|
"tsup": "^8.3.5",
|
|
45
45
|
"tsx": "^4.19.2",
|
|
46
46
|
"typedoc": "^0.26.11",
|
|
47
47
|
"typedoc-json-parser": "^10.2.0",
|
|
48
48
|
"typescript": "~5.4.5",
|
|
49
|
-
"vitest": "^2.1.
|
|
49
|
+
"vitest": "^2.1.8"
|
|
50
50
|
},
|
|
51
51
|
"repository": {
|
|
52
52
|
"type": "git",
|