@sapphire/decorators 7.0.0-pr-589.aa473f9.0 → 7.0.0-pr-935.7da5c8bb

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/CHANGELOG.md CHANGED
@@ -2,6 +2,61 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ # [@sapphire/decorators@6.2.0](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@6.1.1...@sapphire/decorators@6.2.0) - (2025-06-11)
6
+
7
+ ## 🐛 Bug Fixes
8
+
9
+ - **deps:** Update all non-major dependencies ([4bc5591](https://github.com/sapphiredev/utilities/commit/4bc55911f95456a2caee10a3588c7b5f1542fb00)) ([#879](https://github.com/sapphiredev/utilities/pull/879) by @renovate[bot])
10
+ - **deps:** Update all non-major dependencies ([bc2f01c](https://github.com/sapphiredev/utilities/commit/bc2f01ce7d6932c9a0e02faa7cc081ecbae9640d)) ([#869](https://github.com/sapphiredev/utilities/pull/869) by @renovate[bot])
11
+
12
+ ## 🚀 Features
13
+
14
+ - **decorators:** Register application commands decorators ([da07d09](https://github.com/sapphiredev/utilities/commit/da07d0985da60c6c556ad4ead9c7a9fd20cd619d)) ([#877](https://github.com/sapphiredev/utilities/pull/877) by @yuansheng1549)
15
+
16
+ # [@sapphire/decorators@6.1.1](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@6.1.0...@sapphire/decorators@6.1.1) - (2024-11-02)
17
+
18
+ ## 🏠 Refactor
19
+
20
+ - Resolve several sonar issues ([ba915f9](https://github.com/sapphiredev/utilities/commit/ba915f93ce0907828ba17b2d5ae009631ceb860d)) ([#823](https://github.com/sapphiredev/utilities/pull/823) by @favna)
21
+
22
+ ## 🐛 Bug Fixes
23
+
24
+ - **deps:** Update all non-major dependencies ([083376a](https://github.com/sapphiredev/utilities/commit/083376aac55094dbeddb5194e8a8f0d794b8cceb)) ([#763](https://github.com/sapphiredev/utilities/pull/763) by @renovate[bot])
25
+ - **deps:** Update all non-major dependencies ([e7fdc5d](https://github.com/sapphiredev/utilities/commit/e7fdc5db3632a7f90292ef3978898da32730343a)) ([#752](https://github.com/sapphiredev/utilities/pull/752) by @renovate[bot])
26
+
27
+ ## 📝 Documentation
28
+
29
+ - **decorator:** Fix tsdoc comments ([97dd5ac](https://github.com/sapphiredev/utilities/commit/97dd5ac6fdaedbcbf56e99fa566b09133b745b75))
30
+
31
+ # [@sapphire/decorators@6.1.0](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@6.0.4...@sapphire/decorators@6.1.0) - (2024-03-17)
32
+
33
+ ## 🚀 Features
34
+
35
+ - Add-interaction-support-to-decorators (#725) ([c166ac6](https://github.com/sapphiredev/utilities/commit/c166ac6e8c2ae4c8057a84e08e7f6b4339f5a0f6))
36
+
37
+ # [@sapphire/decorators@6.0.4](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@6.0.4...@sapphire/decorators@6.0.4) - (2024-01-19)
38
+
39
+ ## 🐛 Bug Fixes
40
+
41
+ - Fixed commonjs typings export mapping (#707) ([216ff02](https://github.com/sapphiredev/utilities/commit/216ff0260d63a9590357f9a5069f1ae2b34eaf5d))
42
+
43
+ # [@sapphire/decorators@6.0.3](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@6.0.3...@sapphire/decorators@6.0.3) - (2023-12-04)
44
+
45
+ ## 🐛 Bug Fixes
46
+
47
+ - **decorators:** Properly split CJS and ESM ([2326c11](https://github.com/sapphiredev/utilities/commit/2326c116cb31ffd7f3c93b25af85ae33e381df35))
48
+ - Update export mapping for proper ESM/CJS split ([dd0cff8](https://github.com/sapphiredev/utilities/commit/dd0cff8e9b03a15812f25f7a1180501a92422629))
49
+
50
+ # [@sapphire/decorators@6.0.2](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@6.0.1...@sapphire/decorators@6.0.2) - (2023-07-21)
51
+
52
+ ## 🐛 Bug Fixes
53
+
54
+ - **deps:** Update all non-major dependencies (#607) ([9cc8bd0](https://github.com/sapphiredev/utilities/commit/9cc8bd0d4b5d650deab2c913e6c3d713861bae28))
55
+
56
+ ## 🧪 Testing
57
+
58
+ - Update vitest to coverage v8 ([a4bc6e4](https://github.com/sapphiredev/utilities/commit/a4bc6e4f24ea60143a150ecc76fda6484f172ab9))
59
+
5
60
  # [@sapphire/decorators@6.0.1](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@6.0.0...@sapphire/decorators@6.0.1) - (2023-04-10)
6
61
 
7
62
  ## 🐛 Bug Fixes
package/README.md CHANGED
@@ -7,7 +7,6 @@
7
7
  **Useful TypeScript decorators for Sapphire Framework bots.**
8
8
 
9
9
  [![GitHub](https://img.shields.io/github/license/sapphiredev/utilities)](https://github.com/sapphiredev/utilities/blob/main/LICENSE.md)
10
- [![codecov](https://codecov.io/gh/sapphiredev/utilities/branch/main/graph/badge.svg?token=OEGIV6RFDO)](https://codecov.io/gh/sapphiredev/utilities)
11
10
  [![npm bundle size](https://img.shields.io/bundlephobia/min/@sapphire/decorators?logo=webpack&style=flat-square)](https://bundlephobia.com/result?p=@sapphire/decorators)
12
11
  [![npm](https://img.shields.io/npm/v/@sapphire/decorators?color=crimson&logo=npm&style=flat-square)](https://www.npmjs.com/package/@sapphire/decorators)
13
12
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  var discord_jsUtilities = require('@sapphire/discord.js-utilities');
4
4
  var framework = require('@sapphire/framework');
5
+ var utilities = require('@sapphire/utilities');
5
6
  var discord_js = require('discord.js');
6
7
 
7
8
  var __defProp = Object.defineProperty;
@@ -19,10 +20,8 @@ __name(createClassDecorator, "createClassDecorator");
19
20
  function createFunctionPrecondition(precondition, fallback = () => void 0) {
20
21
  return createMethodDecorator((_target, _propertyKey, descriptor) => {
21
22
  const method = descriptor.value;
22
- if (!method)
23
- throw new Error("Function preconditions require a [[value]].");
24
- if (typeof method !== "function")
25
- 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.");
26
25
  descriptor.value = /* @__PURE__ */ __name(async function descriptorValue(...args) {
27
26
  const canRun = await precondition(...args);
28
27
  return canRun ? method.call(this, ...args) : fallback.call(this, ...args);
@@ -33,10 +32,10 @@ __name(createFunctionPrecondition, "createFunctionPrecondition");
33
32
  function createProxy(target, handler) {
34
33
  return new Proxy(target, {
35
34
  ...handler,
36
- get: (target2, property) => {
35
+ get: /* @__PURE__ */ __name((target2, property) => {
37
36
  const value = Reflect.get(target2, property);
38
37
  return typeof value === "function" ? (...args) => value.apply(target2, args) : value;
39
- }
38
+ }, "get")
40
39
  });
41
40
  }
42
41
  __name(createProxy, "createProxy");
@@ -99,15 +98,17 @@ var DMAvailableUserPermissions = new discord_js.PermissionsBitField(
99
98
  var RequiresClientPermissions = /* @__PURE__ */ __name((...permissionsResolvable) => {
100
99
  const resolved = new discord_js.PermissionsBitField(permissionsResolvable);
101
100
  const resolvedIncludesServerPermissions = Boolean(resolved.bitfield & DMAvailablePermissions.bitfield);
102
- return createFunctionPrecondition((message) => {
103
- if (resolvedIncludesServerPermissions && discord_jsUtilities.isDMChannel(message.channel)) {
101
+ return createFunctionPrecondition((context) => {
102
+ const { channel } = context;
103
+ const member = context.guild?.members.me;
104
+ if (resolvedIncludesServerPermissions && discord_jsUtilities.isDMChannel(channel)) {
104
105
  throw new framework.UserError({
105
106
  identifier: "requiresClientPermissionsGuildOnly" /* RequiresClientPermissionsGuildOnly */,
106
107
  message: "Sorry, but that command can only be used in a server because I do not have sufficient permissions in DMs"
107
108
  });
108
109
  }
109
- if (discord_jsUtilities.isGuildBasedChannel(message.channel)) {
110
- const missingPermissions = message.channel.permissionsFor(message.guild.members.me).missing(resolved);
110
+ if (discord_jsUtilities.isGuildBasedChannel(channel) && !utilities.isNullish(member)) {
111
+ const missingPermissions = channel.permissionsFor(member).missing(resolved);
111
112
  if (missingPermissions.length) {
112
113
  throw new framework.UserError({
113
114
  identifier: "requiresClientPermissionsMissingPermissions" /* RequiresClientPermissionsMissingPermissions */,
@@ -124,15 +125,17 @@ var RequiresClientPermissions = /* @__PURE__ */ __name((...permissionsResolvable
124
125
  var RequiresUserPermissions = /* @__PURE__ */ __name((...permissionsResolvable) => {
125
126
  const resolved = new discord_js.PermissionsBitField(permissionsResolvable);
126
127
  const resolvedIncludesServerPermissions = Boolean(resolved.bitfield & DMAvailableUserPermissions.bitfield);
127
- return createFunctionPrecondition((message) => {
128
- if (resolvedIncludesServerPermissions && discord_jsUtilities.isDMChannel(message.channel)) {
128
+ return createFunctionPrecondition((context) => {
129
+ const { channel } = context;
130
+ const member = context.guild?.members.me;
131
+ if (resolvedIncludesServerPermissions && discord_jsUtilities.isDMChannel(channel)) {
129
132
  throw new framework.UserError({
130
133
  identifier: "requiresUserPermissionsGuildOnly" /* RequiresUserPermissionsGuildOnly */,
131
134
  message: "Sorry, but that command can only be used in a server because you do not have sufficient permissions in DMs"
132
135
  });
133
136
  }
134
- if (discord_jsUtilities.isGuildBasedChannel(message.channel)) {
135
- const missingPermissions = message.channel.permissionsFor(message.member).missing(resolved);
137
+ if (discord_jsUtilities.isGuildBasedChannel(channel) && !utilities.isNullish(member)) {
138
+ const missingPermissions = channel.permissionsFor(member).missing(resolved);
136
139
  if (missingPermissions.length) {
137
140
  throw new framework.UserError({
138
141
  identifier: "requiresUserPermissionsMissingPermissions" /* RequiresUserPermissionsMissingPermissions */,
@@ -147,29 +150,97 @@ var RequiresUserPermissions = /* @__PURE__ */ __name((...permissionsResolvable)
147
150
  });
148
151
  }, "RequiresUserPermissions");
149
152
  function RequiresGuildContext(fallback = () => void 0) {
150
- return createFunctionPrecondition((message) => message.guild !== null, fallback);
153
+ return createFunctionPrecondition((context) => context.guild !== null, fallback);
151
154
  }
152
155
  __name(RequiresGuildContext, "RequiresGuildContext");
153
156
  function RequiresDMContext(fallback = () => void 0) {
154
- return createFunctionPrecondition((message) => message.guild === null, fallback);
157
+ return createFunctionPrecondition((context) => context.guild === null, fallback);
155
158
  }
156
159
  __name(RequiresDMContext, "RequiresDMContext");
160
+ var applicationDecoratorsMap = /* @__PURE__ */ new WeakMap();
161
+ var proxyApplicationCommandToOriginal = /* @__PURE__ */ new WeakMap();
162
+ var originalApplicationCommandToProxy = /* @__PURE__ */ new WeakMap();
157
163
  function ApplyOptions(optionsOrFn) {
158
164
  return createClassDecorator(
159
165
  (target) => createProxy(target, {
160
- construct: (ctor, [context, baseOptions = {}]) => new ctor(context, {
166
+ construct: /* @__PURE__ */ __name((ctor, [context, baseOptions = {}]) => new ctor(context, {
161
167
  ...baseOptions,
162
168
  ...typeof optionsOrFn === "function" ? optionsOrFn({ container: framework.container, context }) : optionsOrFn
163
- })
169
+ }), "construct")
164
170
  })
165
171
  );
166
172
  }
167
173
  __name(ApplyOptions, "ApplyOptions");
174
+ function RegisterChatInputCommand(optionsFn, registryOptions) {
175
+ return createClassDecorator(
176
+ (target) => collectApplicationCommandDecorators(target, { type: "RegisterChatInputCommand", optionsFn, registryOptions })
177
+ );
178
+ }
179
+ __name(RegisterChatInputCommand, "RegisterChatInputCommand");
180
+ function RegisterMessageContextMenuCommand(optionsFn, registryOptions) {
181
+ return createClassDecorator(
182
+ (target) => collectApplicationCommandDecorators(target, { type: "RegisterMessageContextMenuCommand", optionsFn, registryOptions })
183
+ );
184
+ }
185
+ __name(RegisterMessageContextMenuCommand, "RegisterMessageContextMenuCommand");
186
+ function RegisterUserContextMenuCommand(optionsFn, registryOptions) {
187
+ return createClassDecorator(
188
+ (target) => collectApplicationCommandDecorators(target, { type: "RegisterUserContextMenuCommand", optionsFn, registryOptions })
189
+ );
190
+ }
191
+ __name(RegisterUserContextMenuCommand, "RegisterUserContextMenuCommand");
192
+ function collectApplicationCommandDecorators(target, decorator) {
193
+ const original = proxyApplicationCommandToOriginal.get(target) ?? target;
194
+ const exisiting = applicationDecoratorsMap.get(original) ?? [];
195
+ exisiting.push(decorator);
196
+ applicationDecoratorsMap.set(original, exisiting);
197
+ if (originalApplicationCommandToProxy.has(original)) return originalApplicationCommandToProxy.get(original);
198
+ const proxied = createProxy(target, {
199
+ construct(originalTarget, argArray) {
200
+ const command = Reflect.construct(originalTarget, argArray);
201
+ const decorators = applicationDecoratorsMap.get(original);
202
+ const originalRegister = command.registerApplicationCommands?.bind(command);
203
+ command.registerApplicationCommands = /* @__PURE__ */ __name(function registerApplicationCommands(registry) {
204
+ for (const deco of decorators) {
205
+ switch (deco.type) {
206
+ case "RegisterChatInputCommand": {
207
+ registry.registerChatInputCommand((builder) => deco.optionsFn(builder, command), deco.registryOptions);
208
+ break;
209
+ }
210
+ case "RegisterMessageContextMenuCommand": {
211
+ registry.registerContextMenuCommand(
212
+ (builder) => deco.optionsFn(builder, command).setType(discord_js.ApplicationCommandType.Message),
213
+ deco.registryOptions
214
+ );
215
+ break;
216
+ }
217
+ case "RegisterUserContextMenuCommand": {
218
+ registry.registerContextMenuCommand(
219
+ (builder) => deco.optionsFn(builder, command).setType(discord_js.ApplicationCommandType.User),
220
+ deco.registryOptions
221
+ );
222
+ break;
223
+ }
224
+ }
225
+ }
226
+ if (originalRegister) return originalRegister.call(this, registry);
227
+ }, "registerApplicationCommands");
228
+ return command;
229
+ }
230
+ });
231
+ proxyApplicationCommandToOriginal.set(proxied, original);
232
+ originalApplicationCommandToProxy.set(original, proxied);
233
+ return proxied;
234
+ }
235
+ __name(collectApplicationCommandDecorators, "collectApplicationCommandDecorators");
168
236
 
169
237
  exports.ApplyOptions = ApplyOptions;
170
238
  exports.DecoratorIdentifiers = DecoratorIdentifiers;
171
239
  exports.Enumerable = Enumerable;
172
240
  exports.EnumerableMethod = EnumerableMethod;
241
+ exports.RegisterChatInputCommand = RegisterChatInputCommand;
242
+ exports.RegisterMessageContextMenuCommand = RegisterMessageContextMenuCommand;
243
+ exports.RegisterUserContextMenuCommand = RegisterUserContextMenuCommand;
173
244
  exports.RequiresClientPermissions = RequiresClientPermissions;
174
245
  exports.RequiresDMContext = RequiresDMContext;
175
246
  exports.RequiresGuildContext = RequiresGuildContext;
@@ -178,5 +249,5 @@ exports.createClassDecorator = createClassDecorator;
178
249
  exports.createFunctionPrecondition = createFunctionPrecondition;
179
250
  exports.createMethodDecorator = createMethodDecorator;
180
251
  exports.createProxy = createProxy;
181
- //# sourceMappingURL=out.js.map
182
- //# sourceMappingURL=index.js.map
252
+ //# sourceMappingURL=index.cjs.map
253
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
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","ApplicationCommandType"],"mappings":";;;;;;;;;;;AAiCO,SAAS,sBAAsB,EAAA,EAAsC;AAC3E,EAAA,OAAO,EAAA;AACR;AAFgB,MAAA,CAAA,qBAAA,EAAA,uBAAA,CAAA;AAST,SAAS,qBAAiE,EAAA,EAA+B;AAC/G,EAAA,OAAO,EAAA;AACR;AAFgB,MAAA,CAAA,oBAAA,EAAA,sBAAA,CAAA;AA8BT,SAAS,0BAAA,CAA2B,YAAA,EAAoC,QAAA,GAA6B,MAAY,MAAA,EAA4B;AACnJ,EAAA,OAAO,qBAAA,CAAsB,CAAC,OAAA,EAAS,YAAA,EAAc,UAAA,KAAe;AACnE,IAAA,MAAM,SAAS,UAAA,CAAW,KAAA;AAC1B,IAAA,IAAI,CAAC,MAAA,EAAQ,MAAM,IAAI,MAAM,6CAA6C,CAAA;AAC1E,IAAA,IAAI,OAAO,MAAA,KAAW,UAAA,EAAY,MAAM,IAAI,MAAM,0DAA0D,CAAA;AAE5G,IAAA,UAAA,CAAW,KAAA,mBAAQ,MAAA,CAAA,eAAe,eAAA,CAAA,GAAkD,IAAA,EAAa;AAChG,MAAA,MAAM,MAAA,GAAS,MAAM,YAAA,CAAa,GAAG,IAAI,CAAA;AACzC,MAAA,OAAO,MAAA,GAAS,MAAA,CAAO,IAAA,CAAK,IAAA,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O,CAAA,EAAG,IAAA,CAAK,eAAe,CAAA;AACrG,cAAA;AAAA,YACD;AAAA,YAEA,KAAK,mCAAA,EAAqC;AACzC,cAAA,QAAA,CAAS,0BAAA;AAAA,gBACR,CAAC,YAAY,IAAA,CAAK,SAAA,CAAU,SAAS,OAAO,CAAA,CAAE,OAAA,CAAQC,iCAAA,CAAuB,OAAO,CAAA;AAAA,gBACpF,IAAA,CAAK;AAAA,eACN;AACA,cAAA;AAAA,YACD;AAAA,YAEA,KAAK,gCAAA,EAAkC;AACtC,cAAA,QAAA,CAAS,0BAAA;AAAA,gBACR,CAAC,YAAY,IAAA,CAAK,SAAA,CAAU,SAAS,OAAO,CAAA,CAAE,OAAA,CAAQA,iCAAA,CAAuB,IAAI,CAAA;AAAA,gBACjF,IAAA,CAAK;AAAA,eACN;AACA,cAAA;AAAA,YACD;AAAA;AACD,QACD;AAEA,QAAA,IAAI,gBAAA,EAAkB,OAAO,gBAAA,CAAiB,IAAA,CAAK,MAAM,QAAQ,CAAA;AAAA,MAClE,CAAA,EA3BsC,6BAAA,CAAA;AA6BtC,MAAA,OAAO,OAAA;AAAA,IACR;AAAA,GACA,CAAA;AAED,EAAA,iCAAA,CAAkC,GAAA,CAAI,SAAS,QAAQ,CAAA;AACvD,EAAA,iCAAA,CAAkC,GAAA,CAAI,UAAU,OAAO,CAAA;AAEvD,EAAA,OAAO,OAAA;AACR;AApDS,MAAA,CAAA,mCAAA,EAAA,qCAAA,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 ApplicationCommandRegistryRegisterOptions, type Command, type Piece } from '@sapphire/framework';\nimport type { Container } from '@sapphire/pieces';\nimport type { Ctor } from '@sapphire/utilities';\nimport {\n\tApplicationCommandType,\n\ttype ContextMenuCommandBuilder,\n\ttype SlashCommandBuilder,\n\ttype SlashCommandOptionsOnlyBuilder,\n\ttype SlashCommandSubcommandsOnlyBuilder\n} from 'discord.js';\nimport { createClassDecorator, createProxy } from './utils';\n\nconst applicationDecoratorsMap = new WeakMap<CommandTarget<any>, DecoratorMap<any>[]>();\nconst proxyApplicationCommandToOriginal = new WeakMap<CommandTarget<any>, CommandTarget<any>>();\nconst originalApplicationCommandToProxy = new WeakMap<CommandTarget<any>, CommandTarget<any>>();\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\n/**\n * Decorator for registering chat input command.\n * @param optionsFn The function that returns options to pass to the registry.\n * @example\n * ```typescript\n * import { RegisterChatInputCommand } from '@sapphire/decorators';\n * import { Command } from '@sapphire/framework';\n *\n * (at)RegisterChatInputCommand((builder, command) => builder\n * .setName(command.name)\n * .setDescription(command.description)\n * )\n * export class UserCommand extends Command {\n * \t public override chatInputRun(interaction: Command.ChatInputCommandInteraction) {\n * \t \treturn interaction.reply({ content: 'HI!' });\n * \t }\n * }\n * ```\n * @example\n * ```typescript\n * import { RegisterChatInputCommand } from '@sapphire/decorators';\n * import { Command } from '@sapphire/framework';\n *\n * (at)RegisterChatInputCommand((builder, command) => builder\n *\t\t.setName(command.name)\n *\t\t.setDescription(command.description),\n *\t{\n *\t\tidHints: ['737141877803057244'],\n *\t\tguildIds: ['737141877803057244']\n *\t}\n * )\n * export class UserCommand extends Command {\n * \t public override chatInputRun(interaction: Command.ChatInputCommandInteraction) {\n * \t \treturn interaction.reply({ content: 'HI!' });\n * \t }\n * }\n * ```\n * @example\n * ```typescript\n * import { RegisterChatInputCommand } from '@sapphire/decorators';\n * import { Command } from '@sapphire/framework';\n *\n * (at)RegisterChatInputCommand((builder) => builder\n * .setName('hi')\n * .setDescription('Sends a hi message')\n * )\n * export class UserCommand extends Command {\n * \t public override chatInputRun(interaction: Command.ChatInputCommandInteraction) {\n * \t \treturn interaction.reply({ content: 'HI!' });\n * \t }\n * }\n * ```\n * @example\n * ```typescript\n * import { ApplyOptions, RegisterChatInputCommand } from '@sapphire/decorators';\n * import { Command } from '@sapphire/framework';\n * import type { Message } from 'discord.js';\n *\n * (at)ApplyOptions<Command.Options>({\n * description: 'ping pong',\n * enabled: true\n * })\n * (at)RegisterChatInputCommand((builder, command) => builder\n * .setName(command.name)\n * .setDescription(command.description)\n * )\n * export class UserCommand extends Command { *\n * \t public override chatInputRun(interaction: Command.ChatInputCommandInteraction) {\n * \t \treturn interaction.reply({ content: 'HI!' });\n * \t }\n * }\n * ```\n */\nexport function RegisterChatInputCommand<CMD extends Command = Command>(\n\toptionsFn: ChatInputCommandDecoratorsMap<CMD>['optionsFn'],\n\tregistryOptions?: ApplicationCommandRegistryRegisterOptions\n): ClassDecorator {\n\treturn createClassDecorator((target: CommandTarget<CMD>) =>\n\t\tcollectApplicationCommandDecorators(target, { type: 'RegisterChatInputCommand', optionsFn, registryOptions })\n\t);\n}\n\n/**\n * Decorator for registering message context menu command.\n * @param optionsFn The function that returns options to pass to the registry.\n * @example\n * ```typescript\n * import { RegisterMessageContextMenuCommand } from '@sapphire/decorators';\n * import { Command } from '@sapphire/framework';\n * import { ApplicationIntegrationType, InteractionContextType, type MessageContextMenuCommandInteraction } from 'discord.js';\n *\n * (at)RegisterMessageContextMenuCommand((builder, command) => builder\n * \t .setName(command.name)\n * \t .setContexts(InteractionContextType.Guild)\n * \t .setIntegrationTypes(ApplicationIntegrationType.GuildInstall)\n * )\n * export class UserCommand extends Command {\n * \tpublic override contextMenuRun(interaction: MessageContextMenuCommandInteraction) {\n * \t\treturn interaction.reply({ content: 'HI!' })\n * \t}\n * }\n * ```\n * @example\n * ```typescript\n * import { RegisterMessageContextMenuCommand } from '@sapphire/decorators';\n * import { Command } from '@sapphire/framework';\n * import { ApplicationIntegrationType, InteractionContextType, type MessageContextMenuCommandInteraction } from 'discord.js';\n *\n * (at)RegisterMessageContextMenuCommand((builder, command) => builder\n * \t .setName(command.name)\n * \t .setContexts(InteractionContextType.Guild)\n * \t .setIntegrationTypes(ApplicationIntegrationType.GuildInstall),\n *\t{\n *\t\tidHints: ['737141877803057244'],\n *\t\tguildIds: ['737141877803057244']\n *\t}\n * )\n * export class UserCommand extends Command {\n * \tpublic override contextMenuRun(interaction: MessageContextMenuCommandInteraction) {\n * \t\treturn interaction.reply({ content: 'HI!' })\n * \t}\n * }\n * ```\n * @example\n * ```typescript\n * import { RegisterMessageContextMenuCommand } from '@sapphire/decorators';\n * import { Command } from '@sapphire/framework';\n * import { ApplicationIntegrationType, InteractionContextType, type MessageContextMenuCommandInteraction } from 'discord.js';\n *\n * (at)RegisterMessageContextMenuCommand((builder, command) => builder\n * \t .setName(command.name)\n * \t .setContexts(InteractionContextType.Guild)\n * \t .setIntegrationTypes(ApplicationIntegrationType.GuildInstall)\n * )\n * export class UserCommand extends Command {\n * \tpublic override contextMenuRun(interaction: MessageContextMenuCommandInteraction) {\n * \t\treturn interaction.reply({ content: 'HI!' })\n * \t}\n * }\n * ```\n * @example\n * ```typescript\n * import { RegisterMessageContextMenuCommand } from '@sapphire/decorators';\n * import { Command } from '@sapphire/framework';\n * import { ApplicationIntegrationType, InteractionContextType, type MessageContextMenuCommandInteraction } from 'discord.js';\n *\n * (at)RegisterMessageContextMenuCommand((builder) => builder\n * \t .setName('Send HI')\n * \t .setContexts(InteractionContextType.Guild)\n * \t .setIntegrationTypes(ApplicationIntegrationType.GuildInstall)\n * )\n * export class UserCommand extends Command {\n * \tpublic override contextMenuRun(interaction: MessageContextMenuCommandInteraction) {\n * \t\treturn interaction.reply({ content: 'HI!' })\n * \t}\n * }\n * ```\n * @example\n * ```typescript\n * import { ApplyOptions, RegisterMessageContextMenuCommand } from '@sapphire/decorators';\n * import { Command } from '@sapphire/framework';\n * import { ApplicationIntegrationType, InteractionContextType, type MessageContextMenuCommandInteraction } from 'discord.js';\n *\n * (at)ApplyOptions<Command.Options>({\n * enabled: true\n * })\n * (at)RegisterMessageContextMenuCommand((builder, command) => builder\n * \t .setName(command.name)\n * \t .setContexts(InteractionContextType.Guild)\n * \t .setIntegrationTypes(ApplicationIntegrationType.GuildInstall)\n * )\n * export class UserCommand extends Command {\n * \tpublic override contextMenuRun(interaction: MessageContextMenuCommandInteraction) {\n * \t\treturn interaction.reply({ content: 'HI!' })\n * \t}\n * }\n * ```\n */\nexport function RegisterMessageContextMenuCommand<CMD extends Command = Command>(\n\toptionsFn: ContextMenuCommandDecoratorsMap<CMD>['optionsFn'],\n\tregistryOptions?: ApplicationCommandRegistryRegisterOptions\n): ClassDecorator {\n\treturn createClassDecorator((target: CommandTarget<CMD>) =>\n\t\tcollectApplicationCommandDecorators(target, { type: 'RegisterMessageContextMenuCommand', optionsFn, registryOptions })\n\t);\n}\n\n/**\n * Decorator for registering user context menu command.\n * @param optionsFn The function that returns options to pass to the registry.\n * @example\n * ```typescript\n * import { RegisterUserContextMenuCommand } from '@sapphire/decorators';\n * import { Command } from '@sapphire/framework';\n * import { ApplicationIntegrationType, InteractionContextType, type UserContextMenuCommandInteraction } from 'discord.js';\n *\n * (at)RegisterUserContextMenuCommand((builder, command) => builder\n * \t .setName(command.name)\n * \t .setContexts(InteractionContextType.Guild)\n * \t .setIntegrationTypes(ApplicationIntegrationType.GuildInstall)\n * )\n * export class UserCommand extends Command {\n * \tpublic override contextMenuRun(interaction: UserContextMenuCommandInteraction) {\n * \t\treturn interaction.reply({ content: 'HI!' })\n * \t}\n * }\n * ```\n * ```\n * @example\n * ```typescript\n * import { RegisterUserContextMenuCommand } from '@sapphire/decorators';\n * import { Command } from '@sapphire/framework';\n * import { ApplicationIntegrationType, InteractionContextType, type MessageContextMenuCommandInteraction } from 'discord.js';\n *\n * (at)RegisterUserContextMenuCommand((builder, command) => builder\n * \t .setName(command.name)\n * \t .setContexts(InteractionContextType.Guild)\n * \t .setIntegrationTypes(ApplicationIntegrationType.GuildInstall),\n *\t{\n *\t\tidHints: ['737141877803057244'],\n *\t\tguildIds: ['737141877803057244']\n *\t}\n * )\n * export class UserCommand extends Command {\n * \tpublic override contextMenuRun(interaction: MessageContextMenuCommandInteraction) {\n * \t\treturn interaction.reply({ content: 'HI!' })\n * \t}\n * }\n * ```\n * @example\n * ```typescript\n * import { RegisterUserContextMenuCommand } from '@sapphire/decorators';\n * import { Command } from '@sapphire/framework';\n * import { ApplicationIntegrationType, InteractionContextType, type UserContextMenuCommandInteraction } from 'discord.js';\n *\n * (at)RegisterUserContextMenuCommand((builder, command) => builder\n * \t .setName('Send HI')\n * \t .setContexts(InteractionContextType.Guild)\n * \t .setIntegrationTypes(ApplicationIntegrationType.GuildInstall)\n * )\n * export class UserCommand extends Command {\n * \tpublic override contextMenuRun(interaction: UserContextMenuCommandInteraction) {\n * \t\treturn interaction.reply({ content: `HI ${interaction.targetUser}!` })\n * \t}\n * }\n * ```\n * @example\n * ```typescript\n * import { ApplyOptions, RegisterUserContextMenuCommand } from '@sapphire/decorators';\n * import { Command } from '@sapphire/framework';\n * import { ApplicationIntegrationType, InteractionContextType, type UserContextMenuCommandInteraction } from 'discord.js';\n *\n * (at)ApplyOptions<Command.Options>({\n * enabled: true\n * })\n * (at)RegisterUserContextMenuCommand((builder, command) => builder\n * \t .setName(command.name)\n * \t .setContexts(InteractionContextType.Guild)\n * \t .setIntegrationTypes(ApplicationIntegrationType.GuildInstall)\n * )\n * export class UserCommand extends Command {\n * \tpublic override contextMenuRun(interaction: MessageContextMenuCommandInteraction) {\n * \t\treturn interaction.reply({ content: 'HI!' })\n * \t}\n * }\n * ```\n */\nexport function RegisterUserContextMenuCommand<CMD extends Command = Command>(\n\toptionsFn: ContextMenuCommandDecoratorsMap<CMD>['optionsFn'],\n\tregistryOptions?: ApplicationCommandRegistryRegisterOptions\n): ClassDecorator {\n\treturn createClassDecorator((target: CommandTarget<CMD>) =>\n\t\tcollectApplicationCommandDecorators(target, { type: 'RegisterUserContextMenuCommand', optionsFn, registryOptions })\n\t);\n}\n\nfunction collectApplicationCommandDecorators<CMD extends Command>(target: CommandTarget<CMD>, decorator: DecoratorMap<CMD>): CommandTarget<CMD> {\n\tconst original = proxyApplicationCommandToOriginal.get(target) ?? target;\n\n\tconst exisiting = applicationDecoratorsMap.get(original) ?? [];\n\texisiting.push(decorator);\n\tapplicationDecoratorsMap.set(original, exisiting);\n\n\tif (originalApplicationCommandToProxy.has(original)) return originalApplicationCommandToProxy.get(original)!;\n\n\tconst proxied = createProxy(target, {\n\t\tconstruct(originalTarget, argArray) {\n\t\t\tconst command: CMD = Reflect.construct(originalTarget, argArray);\n\t\t\tconst decorators = applicationDecoratorsMap.get(original) as DecoratorMap<CMD>[];\n\n\t\t\tconst originalRegister = command.registerApplicationCommands?.bind(command);\n\t\t\tcommand.registerApplicationCommands = function registerApplicationCommands(registry: Command.Registry) {\n\t\t\t\tfor (const deco of decorators) {\n\t\t\t\t\tswitch (deco.type) {\n\t\t\t\t\t\tcase 'RegisterChatInputCommand': {\n\t\t\t\t\t\t\tregistry.registerChatInputCommand((builder) => deco.optionsFn(builder, command), deco.registryOptions);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcase 'RegisterMessageContextMenuCommand': {\n\t\t\t\t\t\t\tregistry.registerContextMenuCommand(\n\t\t\t\t\t\t\t\t(builder) => deco.optionsFn(builder, command).setType(ApplicationCommandType.Message),\n\t\t\t\t\t\t\t\tdeco.registryOptions\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcase 'RegisterUserContextMenuCommand': {\n\t\t\t\t\t\t\tregistry.registerContextMenuCommand(\n\t\t\t\t\t\t\t\t(builder) => deco.optionsFn(builder, command).setType(ApplicationCommandType.User),\n\t\t\t\t\t\t\t\tdeco.registryOptions\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (originalRegister) return originalRegister.call(this, registry);\n\t\t\t};\n\n\t\t\treturn command;\n\t\t}\n\t});\n\n\tproxyApplicationCommandToOriginal.set(proxied, original);\n\toriginalApplicationCommandToProxy.set(original, proxied);\n\n\treturn proxied;\n}\n\nexport interface ApplyOptionsCallbackParameters {\n\tcontainer: Container;\n\tcontext: Piece.LoaderContext;\n}\n\ninterface ChatInputCommandDecoratorsMap<CMD extends Command> {\n\ttype: 'RegisterChatInputCommand';\n\toptionsFn: (\n\t\tbuilder: SlashCommandBuilder,\n\t\tcommand: ThisType<CMD> & CMD\n\t) => SlashCommandBuilder | SlashCommandSubcommandsOnlyBuilder | SlashCommandOptionsOnlyBuilder;\n\tregistryOptions?: ApplicationCommandRegistryRegisterOptions;\n}\n\ninterface ContextMenuCommandDecoratorsMap<CMD extends Command> {\n\ttype: 'RegisterMessageContextMenuCommand' | 'RegisterUserContextMenuCommand';\n\toptionsFn: (\n\t\tbuilder: ContextMenuCommandBuilder, //\n\t\tcommand: ThisType<CMD> & CMD\n\t) => ContextMenuCommandBuilder;\n\tregistryOptions?: ApplicationCommandRegistryRegisterOptions;\n}\n\ntype CommandTarget<CMD extends Command> = Ctor<ConstructorParameters<typeof Command>, CMD>;\ntype DecoratorMap<CMD extends Command> = ChatInputCommandDecoratorsMap<CMD> | ContextMenuCommandDecoratorsMap<CMD>;\n"]}