@sapphire/decorators 6.1.1-next.f4635450.0 → 6.1.1-next.f63a9a11

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.
@@ -20,10 +20,8 @@ __name(createClassDecorator, "createClassDecorator");
20
20
  function createFunctionPrecondition(precondition, fallback = () => void 0) {
21
21
  return createMethodDecorator((_target, _propertyKey, descriptor) => {
22
22
  const method = descriptor.value;
23
- if (!method)
24
- throw new Error("Function preconditions require a [[value]].");
25
- if (typeof method !== "function")
26
- throw new Error("Function preconditions can only be applied to functions.");
23
+ if (!method) throw new Error("Function preconditions require a [[value]].");
24
+ if (typeof method !== "function") throw new Error("Function preconditions can only be applied to functions.");
27
25
  descriptor.value = /* @__PURE__ */ __name(async function descriptorValue(...args) {
28
26
  const canRun = await precondition(...args);
29
27
  return canRun ? method.call(this, ...args) : fallback.call(this, ...args);
@@ -34,10 +32,10 @@ __name(createFunctionPrecondition, "createFunctionPrecondition");
34
32
  function createProxy(target, handler) {
35
33
  return new Proxy(target, {
36
34
  ...handler,
37
- get: (target2, property) => {
35
+ get: /* @__PURE__ */ __name((target2, property) => {
38
36
  const value = Reflect.get(target2, property);
39
37
  return typeof value === "function" ? (...args) => value.apply(target2, args) : value;
40
- }
38
+ }, "get")
41
39
  });
42
40
  }
43
41
  __name(createProxy, "createProxy");
@@ -162,10 +160,10 @@ __name(RequiresDMContext, "RequiresDMContext");
162
160
  function ApplyOptions(optionsOrFn) {
163
161
  return createClassDecorator(
164
162
  (target) => createProxy(target, {
165
- construct: (ctor, [context, baseOptions = {}]) => new ctor(context, {
163
+ construct: /* @__PURE__ */ __name((ctor, [context, baseOptions = {}]) => new ctor(context, {
166
164
  ...baseOptions,
167
165
  ...typeof optionsOrFn === "function" ? optionsOrFn({ container: framework.container, context }) : optionsOrFn
168
- })
166
+ }), "construct")
169
167
  })
170
168
  );
171
169
  }
@@ -183,5 +181,5 @@ exports.createClassDecorator = createClassDecorator;
183
181
  exports.createFunctionPrecondition = createFunctionPrecondition;
184
182
  exports.createMethodDecorator = createMethodDecorator;
185
183
  exports.createProxy = createProxy;
186
- //# sourceMappingURL=out.js.map
184
+ //# sourceMappingURL=index.cjs.map
187
185
  //# sourceMappingURL=index.cjs.map
@@ -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,IAAsC;AAC3E,SAAO;AACR;AAFgB;AAST,SAAS,qBAAiE,IAA+B;AAC/G,SAAO;AACR;AAFgB;AA8BT,SAAS,2BAA2B,cAAoC,WAA6B,MAAY,QAA4B;AACnJ,SAAO,sBAAsB,CAAC,SAAS,cAAc,eAAe;AACnE,UAAM,SAAS,WAAW;AAC1B,QAAI,CAAC;AAAQ,YAAM,IAAI,MAAM,6CAA6C;AAC1E,QAAI,OAAO,WAAW;AAAY,YAAM,IAAI,MAAM,0DAA0D;AAE5G,eAAW,QAAQ,sCAAe,mBAAkD,MAAa;AAChG,YAAM,SAAS,MAAM,aAAa,GAAG,IAAI;AACzC,aAAO,SAAS,OAAO,KAAK,MAAM,GAAG,IAAI,IAAI,SAAS,KAAK,MAAM,GAAG,IAAI;AAAA,IACzE,GAHmB;AAAA,EAIpB,CAAC;AACF;AAXgB;AAmBT,SAAS,YAA8B,QAAW,SAA0C;AAClG,SAAO,IAAI,MAAM,QAAQ;AAAA,IACxB,GAAG;AAAA,IACH,KAAK,CAACA,SAAQ,aAAa;AAC1B,YAAM,QAAQ,QAAQ,IAAIA,SAAQ,QAAQ;AAC1C,aAAO,OAAO,UAAU,aAAa,IAAI,SAA6B,MAAM,MAAMA,SAAQ,IAAI,IAAI;AAAA,IACnG;AAAA,EACD,CAAC;AACF;AARgB;;;ACpFT,SAAS,WAAW,OAAgB;AAC1C,SAAO,CAAC,QAAiB,QAAgB;AACxC,YAAQ,eAAe,QAAyB,KAAK;AAAA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;AAAA,UAC1G,SAAS;AAAA,YACR,SAAS;AAAA,UACV;AAAA,QACD,CAAC;AAAA,MACF;AAAA,IACD;AAEA,WAAO;AAAA,EACR,CAAC;AACF,GA/BuC;AAsChC,SAAS,qBAAqB,WAA6B,MAAY,QAA4B;AACzG,SAAO,2BAA2B,CAAC,YAAuC,QAAQ,UAAU,MAAM,QAAQ;AAC3G;AAFgB;AAST,SAAS,kBAAkB,WAA6B,MAAY,QAA4B;AACtG,SAAO,2BAA2B,CAAC,YAAuC,QAAQ,UAAU,MAAM,QAAQ;AAC3G;AAFgB;;;ACtMhB,SAAS,iBAA6B;AAmD/B,SAAS,aAAsC,aAAsF;AAC3I,SAAO;AAAA,IAAqB,CAAC,WAC5B,YAAY,QAAQ;AAAA,MACnB,WAAW,CAAC,MAAM,CAAC,SAAS,cAAc,CAAC,CAAC,MAC3C,IAAI,KAAK,SAAS;AAAA,QACjB,GAAG;AAAA,QACH,GAAI,OAAO,gBAAgB,aAAa,YAAY,EAAE,WAAW,QAAQ,CAAC,IAAI;AAAA,MAC/E,CAAC;AAAA,IACH,CAAC;AAAA,EACF;AACD;AAVgB","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 type { NonNullObject } from '@sapphire/utilities';\nimport { 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: unknown, key: string) => {\n\t\tReflect.defineProperty(target as NonNullObject, key, {\n\t\t\tenumerable: value,\n\t\t\tset(this: unknown, val: unknown) {\n\t\t\t\tReflect.defineProperty(this as NonNullObject, 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 options The 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.Context, 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.Context;\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,CAAA;AACR,CAAA;AAFgB,MAAA,CAAA,qBAAA,EAAA,uBAAA,CAAA,CAAA;AAST,SAAS,qBAAiE,EAA+B,EAAA;AAC/G,EAAO,OAAA,EAAA,CAAA;AACR,CAAA;AAFgB,MAAA,CAAA,oBAAA,EAAA,sBAAA,CAAA,CAAA;AA8BT,SAAS,0BAA2B,CAAA,YAAA,EAAoC,QAA6B,GAAA,MAAY,KAA4B,CAAA,EAAA;AACnJ,EAAA,OAAO,qBAAsB,CAAA,CAAC,OAAS,EAAA,YAAA,EAAc,UAAe,KAAA;AACnE,IAAA,MAAM,SAAS,UAAW,CAAA,KAAA,CAAA;AAC1B,IAAA,IAAI,CAAC,MA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A,OAC9E,CAJS,EAAA,WAAA,CAAA;AAAA,KAKX,CAAA;AAAA,GACF,CAAA;AACD,CAAA;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 type { NonNullObject } from '@sapphire/utilities';\nimport { 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: unknown, key: string) => {\n\t\tReflect.defineProperty(target as NonNullObject, key, {\n\t\t\tenumerable: value,\n\t\t\tset(this: unknown, val: unknown) {\n\t\t\t\tReflect.defineProperty(this as NonNullObject, 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"]}
@@ -187,7 +187,7 @@ declare function RequiresDMContext(fallback?: FunctionFallback): MethodDecorator
187
187
 
188
188
  /**
189
189
  * Decorator function that applies given options to any Sapphire piece
190
- * @param options The options to pass to the piece constructor
190
+ * @param optionsOrFn The options or function that returns options to pass to the piece constructor
191
191
  * @example
192
192
  * ```typescript
193
193
  * import { ApplyOptions } from '@sapphire/decorators';
@@ -234,7 +234,7 @@ declare function RequiresDMContext(fallback?: FunctionFallback): MethodDecorator
234
234
  declare function ApplyOptions<T extends Piece.Options>(optionsOrFn: T | ((parameters: ApplyOptionsCallbackParameters) => T)): ClassDecorator;
235
235
  interface ApplyOptionsCallbackParameters {
236
236
  container: Container;
237
- context: Piece.Context;
237
+ context: Piece.LoaderContext;
238
238
  }
239
239
 
240
240
  export { ApplyOptions, type ApplyOptionsCallbackParameters, DecoratorIdentifiers, Enumerable, EnumerableMethod, type FunctionFallback, type FunctionPrecondition, RequiresClientPermissions, RequiresDMContext, RequiresGuildContext, RequiresUserPermissions, createClassDecorator, createFunctionPrecondition, createMethodDecorator, createProxy };
@@ -187,7 +187,7 @@ declare function RequiresDMContext(fallback?: FunctionFallback): MethodDecorator
187
187
 
188
188
  /**
189
189
  * Decorator function that applies given options to any Sapphire piece
190
- * @param options The options to pass to the piece constructor
190
+ * @param optionsOrFn The options or function that returns options to pass to the piece constructor
191
191
  * @example
192
192
  * ```typescript
193
193
  * import { ApplyOptions } from '@sapphire/decorators';
@@ -234,7 +234,7 @@ declare function RequiresDMContext(fallback?: FunctionFallback): MethodDecorator
234
234
  declare function ApplyOptions<T extends Piece.Options>(optionsOrFn: T | ((parameters: ApplyOptionsCallbackParameters) => T)): ClassDecorator;
235
235
  interface ApplyOptionsCallbackParameters {
236
236
  container: Container;
237
- context: Piece.Context;
237
+ context: Piece.LoaderContext;
238
238
  }
239
239
 
240
240
  export { ApplyOptions, type ApplyOptionsCallbackParameters, DecoratorIdentifiers, Enumerable, EnumerableMethod, type FunctionFallback, type FunctionPrecondition, RequiresClientPermissions, RequiresDMContext, RequiresGuildContext, RequiresUserPermissions, createClassDecorator, createFunctionPrecondition, createMethodDecorator, createProxy };
@@ -18,10 +18,8 @@ __name(createClassDecorator, "createClassDecorator");
18
18
  function createFunctionPrecondition(precondition, fallback = () => void 0) {
19
19
  return createMethodDecorator((_target, _propertyKey, descriptor) => {
20
20
  const method = descriptor.value;
21
- if (!method)
22
- throw new Error("Function preconditions require a [[value]].");
23
- if (typeof method !== "function")
24
- throw new Error("Function preconditions can only be applied to functions.");
21
+ if (!method) throw new Error("Function preconditions require a [[value]].");
22
+ if (typeof method !== "function") throw new Error("Function preconditions can only be applied to functions.");
25
23
  descriptor.value = /* @__PURE__ */ __name(async function descriptorValue(...args) {
26
24
  const canRun = await precondition(...args);
27
25
  return canRun ? method.call(this, ...args) : fallback.call(this, ...args);
@@ -32,10 +30,10 @@ __name(createFunctionPrecondition, "createFunctionPrecondition");
32
30
  function createProxy(target, handler) {
33
31
  return new Proxy(target, {
34
32
  ...handler,
35
- get: (target2, property) => {
33
+ get: /* @__PURE__ */ __name((target2, property) => {
36
34
  const value = Reflect.get(target2, property);
37
35
  return typeof value === "function" ? (...args) => value.apply(target2, args) : value;
38
- }
36
+ }, "get")
39
37
  });
40
38
  }
41
39
  __name(createProxy, "createProxy");
@@ -160,15 +158,15 @@ __name(RequiresDMContext, "RequiresDMContext");
160
158
  function ApplyOptions(optionsOrFn) {
161
159
  return createClassDecorator(
162
160
  (target) => createProxy(target, {
163
- construct: (ctor, [context, baseOptions = {}]) => new ctor(context, {
161
+ construct: /* @__PURE__ */ __name((ctor, [context, baseOptions = {}]) => new ctor(context, {
164
162
  ...baseOptions,
165
163
  ...typeof optionsOrFn === "function" ? optionsOrFn({ container, context }) : optionsOrFn
166
- })
164
+ }), "construct")
167
165
  })
168
166
  );
169
167
  }
170
168
  __name(ApplyOptions, "ApplyOptions");
171
169
 
172
170
  export { ApplyOptions, DecoratorIdentifiers, Enumerable, EnumerableMethod, RequiresClientPermissions, RequiresDMContext, RequiresGuildContext, RequiresUserPermissions, createClassDecorator, createFunctionPrecondition, createMethodDecorator, createProxy };
173
- //# sourceMappingURL=out.js.map
171
+ //# sourceMappingURL=index.mjs.map
174
172
  //# sourceMappingURL=index.mjs.map
@@ -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,IAAsC;AAC3E,SAAO;AACR;AAFgB;AAST,SAAS,qBAAiE,IAA+B;AAC/G,SAAO;AACR;AAFgB;AA8BT,SAAS,2BAA2B,cAAoC,WAA6B,MAAY,QAA4B;AACnJ,SAAO,sBAAsB,CAAC,SAAS,cAAc,eAAe;AACnE,UAAM,SAAS,WAAW;AAC1B,QAAI,CAAC;AAAQ,YAAM,IAAI,MAAM,6CAA6C;AAC1E,QAAI,OAAO,WAAW;AAAY,YAAM,IAAI,MAAM,0DAA0D;AAE5G,eAAW,QAAQ,sCAAe,mBAAkD,MAAa;AAChG,YAAM,SAAS,MAAM,aAAa,GAAG,IAAI;AACzC,aAAO,SAAS,OAAO,KAAK,MAAM,GAAG,IAAI,IAAI,SAAS,KAAK,MAAM,GAAG,IAAI;AAAA,IACzE,GAHmB;AAAA,EAIpB,CAAC;AACF;AAXgB;AAmBT,SAAS,YAA8B,QAAW,SAA0C;AAClG,SAAO,IAAI,MAAM,QAAQ;AAAA,IACxB,GAAG;AAAA,IACH,KAAK,CAACA,SAAQ,aAAa;AAC1B,YAAM,QAAQ,QAAQ,IAAIA,SAAQ,QAAQ;AAC1C,aAAO,OAAO,UAAU,aAAa,IAAI,SAA6B,MAAM,MAAMA,SAAQ,IAAI,IAAI;AAAA,IACnG;AAAA,EACD,CAAC;AACF;AARgB;;;ACpFT,SAAS,WAAW,OAAgB;AAC1C,SAAO,CAAC,QAAiB,QAAgB;AACxC,YAAQ,eAAe,QAAyB,KAAK;A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AkB;AAAA,UAC1G,SAAS;AAAA,YACR,SAAS;AAAA,UACV;AAAA,QACD,CAAC;AAAA,MACF;AAAA,IACD;AAEA,WAAO;AAAA,EACR,CAAC;AACF,GA/BuC;AAsChC,SAAS,qBAAqB,WAA6B,MAAY,QAA4B;AACzG,SAAO,2BAA2B,CAAC,YAAuC,QAAQ,UAAU,MAAM,QAAQ;AAC3G;AAFgB;AAST,SAAS,kBAAkB,WAA6B,MAAY,QAA4B;AACtG,SAAO,2BAA2B,CAAC,YAAuC,QAAQ,UAAU,MAAM,QAAQ;AAC3G;AAFgB;;;ACtMhB,SAAS,iBAA6B;AAmD/B,SAAS,aAAsC,aAAsF;AAC3I,SAAO;AAAA,IAAqB,CAAC,WAC5B,YAAY,QAAQ;AAAA,MACnB,WAAW,CAAC,MAAM,CAAC,SAAS,cAAc,CAAC,CAAC,MAC3C,IAAI,KAAK,SAAS;AAAA,QACjB,GAAG;AAAA,QACH,GAAI,OAAO,gBAAgB,aAAa,YAAY,EAAE,WAAW,QAAQ,CAAC,IAAI;AAAA,MAC/E,CAAC;AAAA,IACH,CAAC;AAAA,EACF;AACD;AAVgB","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 type { NonNullObject } from '@sapphire/utilities';\nimport { 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: unknown, key: string) => {\n\t\tReflect.defineProperty(target as NonNullObject, key, {\n\t\t\tenumerable: value,\n\t\t\tset(this: unknown, val: unknown) {\n\t\t\t\tReflect.defineProperty(this as NonNullObject, 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 options The 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.Context, 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.Context;\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,CAAA;AACR,CAAA;AAFgB,MAAA,CAAA,qBAAA,EAAA,uBAAA,CAAA,CAAA;AAST,SAAS,qBAAiE,EAA+B,EAAA;AAC/G,EAAO,OAAA,EAAA,CAAA;AACR,CAAA;AAFgB,MAAA,CAAA,oBAAA,EAAA,sBAAA,CAAA,CAAA;AA8BT,SAAS,0BAA2B,CAAA,YAAA,EAAoC,QAA6B,GAAA,MAAY,KAA4B,CAAA,EAAA;AACnJ,EAAA,OAAO,qBAAsB,CAAA,CAAC,OAAS,EAAA,YAAA,EAAc,UAAe,KAAA;AACnE,IAAA,MAAM,SAAS,UAAW,CAAA,KAAA,CAAA;AAC1B,IAAA,IAAI,CAAC,MAAA,EAAc,MAAA,IAAI,MAAM,6CAA6C,CAAA,CAAA;AAC1E,IA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A,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 type { NonNullObject } from '@sapphire/utilities';\nimport { 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: unknown, key: string) => {\n\t\tReflect.defineProperty(target as NonNullObject, key, {\n\t\t\tenumerable: value,\n\t\t\tset(this: unknown, val: unknown) {\n\t\t\t\tReflect.defineProperty(this as NonNullObject, 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.1-next.f4635450.0",
3
+ "version": "6.1.1-next.f63a9a11",
4
4
  "description": "Useful TypeScript decorators for Sapphire Framework Discord bots",
5
5
  "author": "@sapphire",
6
6
  "license": "MIT",
@@ -22,30 +22,31 @@
22
22
  "scripts": {
23
23
  "test": "vitest run",
24
24
  "lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
25
- "build": "tsup && yarn build:rename-cjs-index",
26
- "build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
25
+ "build": "yarn gen-index && tsup && yarn build:rename-cjs-index",
26
+ "build:rename-cjs-index": "tsx ../../scripts/rename-cjs-index.cts",
27
27
  "docs": "typedoc-json-parser",
28
28
  "prepack": "yarn build",
29
29
  "bump": "cliff-jumper",
30
- "check-update": "cliff-jumper --dry-run"
30
+ "check-update": "cliff-jumper --dry-run",
31
+ "gen-index": "tsx ../../scripts/gen-index.cts -w decorators"
31
32
  },
32
33
  "dependencies": {
33
- "tslib": "^2.6.2"
34
+ "tslib": "^2.6.3"
34
35
  },
35
36
  "devDependencies": {
36
- "@favware/cliff-jumper": "^3.0.1",
37
- "@sapphire/discord-utilities": "^3.2.3",
38
- "@sapphire/discord.js-utilities": "^7.1.6",
37
+ "@favware/cliff-jumper": "^4.0.3",
38
+ "@sapphire/discord-utilities": "^3.3.0",
39
+ "@sapphire/discord.js-utilities": "^7.3.0",
39
40
  "@sapphire/ratelimits": "^2.4.9",
40
41
  "@sapphire/result": "^2.6.6",
41
- "@sapphire/utilities": "^3.15.3",
42
- "@vitest/coverage-v8": "^1.4.0",
43
- "tsup": "^8.0.2",
44
- "tsx": "^4.7.2",
45
- "typedoc": "^0.25.12",
46
- "typedoc-json-parser": "^9.0.1",
47
- "typescript": "^5.4.4",
48
- "vitest": "^1.4.0"
42
+ "@sapphire/utilities": "^3.17.0",
43
+ "@vitest/coverage-v8": "^2.0.5",
44
+ "tsup": "^8.2.4",
45
+ "tsx": "^4.17.0",
46
+ "typedoc": "^0.25.13",
47
+ "typedoc-json-parser": "^10.0.0",
48
+ "typescript": "~5.4.5",
49
+ "vitest": "^2.0.5"
49
50
  },
50
51
  "repository": {
51
52
  "type": "git",