@sapphire/decorators 4.3.4 → 4.3.5-next.00da8f1.0

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 ADDED
@@ -0,0 +1,344 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [4.3.4](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@4.3.3...@sapphire/decorators@4.3.4) (2022-04-01)
6
+
7
+ **Note:** Version bump only for package @sapphire/decorators
8
+
9
+ ## [4.3.3](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@4.3.2...@sapphire/decorators@4.3.3) (2022-03-20)
10
+
11
+ **Note:** Version bump only for package @sapphire/decorators
12
+
13
+ ## [4.3.2](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@4.3.1...@sapphire/decorators@4.3.2) (2022-03-20)
14
+
15
+ **Note:** Version bump only for package @sapphire/decorators
16
+
17
+ ## [4.3.1](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@4.3.0...@sapphire/decorators@4.3.1) (2022-03-11)
18
+
19
+ **Note:** Version bump only for package @sapphire/decorators
20
+
21
+ # [4.3.0](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@4.2.6...@sapphire/decorators@4.3.0) (2022-03-06)
22
+
23
+ ### Features
24
+
25
+ - allow module: NodeNext ([#306](https://github.com/sapphiredev/utilities/issues/306)) ([9dc6dd6](https://github.com/sapphiredev/utilities/commit/9dc6dd619efab879bb2b0b3c9e64304e10a67ed6))
26
+
27
+ ## [4.2.6](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@4.2.5...@sapphire/decorators@4.2.6) (2022-03-01)
28
+
29
+ **Note:** Version bump only for package @sapphire/decorators
30
+
31
+ ## [4.2.5](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@4.2.4...@sapphire/decorators@4.2.5) (2022-02-18)
32
+
33
+ **Note:** Version bump only for package @sapphire/decorators
34
+
35
+ ## [4.2.4](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@4.2.3...@sapphire/decorators@4.2.4) (2022-02-15)
36
+
37
+ **Note:** Version bump only for package @sapphire/decorators
38
+
39
+ ## [4.2.3](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@4.2.2...@sapphire/decorators@4.2.3) (2022-02-11)
40
+
41
+ **Note:** Version bump only for package @sapphire/decorators
42
+
43
+ ## [4.2.2](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@4.2.1...@sapphire/decorators@4.2.2) (2022-02-07)
44
+
45
+ **Note:** Version bump only for package @sapphire/decorators
46
+
47
+ ## [4.2.1](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@4.2.0...@sapphire/decorators@4.2.1) (2022-02-06)
48
+
49
+ **Note:** Version bump only for package @sapphire/decorators
50
+
51
+ # [4.2.0](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@4.1.0...@sapphire/decorators@4.2.0) (2022-02-03)
52
+
53
+ ### Features
54
+
55
+ - **ts-config:** add multi-config structure ([#281](https://github.com/sapphiredev/utilities/issues/281)) ([b5191d7](https://github.com/sapphiredev/utilities/commit/b5191d7f2416dc5838590c4ff221454925553e37))
56
+
57
+ # [4.1.0](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@4.0.2...@sapphire/decorators@4.1.0) (2022-01-28)
58
+
59
+ ### Features
60
+
61
+ - change build system to tsup ([#270](https://github.com/sapphiredev/utilities/issues/270)) ([365a53a](https://github.com/sapphiredev/utilities/commit/365a53a5517a01a0926cf28a83c96b63f32ed9f8))
62
+
63
+ ## [4.0.2](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@4.0.1...@sapphire/decorators@4.0.2) (2022-01-21)
64
+
65
+ **Note:** Version bump only for package @sapphire/decorators
66
+
67
+ ## [4.0.1](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@4.0.0...@sapphire/decorators@4.0.1) (2022-01-21)
68
+
69
+ **Note:** Version bump only for package @sapphire/decorators
70
+
71
+ # [4.0.0](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@3.1.6...@sapphire/decorators@4.0.0) (2022-01-16)
72
+
73
+ ### Features
74
+
75
+ - **decorators:** add container to `ApplyOptions` callback ([#258](https://github.com/sapphiredev/utilities/issues/258)) ([d2876b8](https://github.com/sapphiredev/utilities/commit/d2876b83ce2356424e12e63cfe9f9e14c6ce52e0))
76
+ - **decorators:** remove `enumerable` and `enumerableMethod`. Use their PascalCased variants instead. ([38e2977](https://github.com/sapphiredev/utilities/commit/38e2977b8dc061d0d62f076b12808b196e92b73a))
77
+
78
+ ### BREAKING CHANGES
79
+
80
+ - **decorators:** The previously deprecated enumerable`and`enumerableMethod` decorators have been removed. Use their PascalCased variants instead.
81
+ - **decorators:** When using `@ApplyOptions` with a callback function, the single parameter of `PieceContex` been changed to an object, which also has a property of `Container`. Migration change is `@ApplyOptions<Listener.Options>(({ context }) => ({`
82
+
83
+ ## [3.1.6](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@3.1.5...@sapphire/decorators@3.1.6) (2022-01-12)
84
+
85
+ **Note:** Version bump only for package @sapphire/decorators
86
+
87
+ ## [3.1.5](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@3.1.4...@sapphire/decorators@3.1.5) (2022-01-10)
88
+
89
+ **Note:** Version bump only for package @sapphire/decorators
90
+
91
+ ## [3.1.4](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@3.1.3...@sapphire/decorators@3.1.4) (2021-11-06)
92
+
93
+ **Note:** Version bump only for package @sapphire/decorators
94
+
95
+ ## [3.1.3](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@3.1.2...@sapphire/decorators@3.1.3) (2021-10-26)
96
+
97
+ ### Bug Fixes
98
+
99
+ - **docs:** replace command usage of `run` to `messageRun` ([#204](https://github.com/sapphiredev/utilities/issues/204)) ([8279ec0](https://github.com/sapphiredev/utilities/commit/8279ec01e9037fb12e37e872979966c1c2e264e1))
100
+
101
+ ## [3.1.2](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@3.1.1...@sapphire/decorators@3.1.2) (2021-10-17)
102
+
103
+ ### Bug Fixes
104
+
105
+ - allow more node & npm versions in engines field ([5977d2a](https://github.com/sapphiredev/utilities/commit/5977d2a30a4b2cfdf84aff3f33af03ffde1bbec5))
106
+
107
+ ## [3.1.1](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@3.1.0...@sapphire/decorators@3.1.1) (2021-10-11)
108
+
109
+ **Note:** Version bump only for package @sapphire/decorators
110
+
111
+ # [3.1.0](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@3.0.1...@sapphire/decorators@3.1.0) (2021-10-10)
112
+
113
+ **Note:** Version bump only for package @sapphire/decorators
114
+
115
+ ## [3.0.1](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@3.0.0...@sapphire/decorators@3.0.1) (2021-10-08)
116
+
117
+ ### Bug Fixes
118
+
119
+ - **decorators:** properly run postbuild scripts ([b71b7a5](https://github.com/sapphiredev/utilities/commit/b71b7a52ac2f2d64b49dc5835d08c8c6a3625752))
120
+
121
+ # [3.0.0](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@2.2.0...@sapphire/decorators@3.0.0) (2021-10-04)
122
+
123
+ ### Bug Fixes
124
+
125
+ - **discord.js-utilities:** fixed permission error messages grammar ([ea9840b](https://github.com/sapphiredev/utilities/commit/ea9840b258770be20eb576b59d470fb03293f694))
126
+
127
+ ### Features
128
+
129
+ - **decorators:** add `RequiresUserPermissions` ([688e39f](https://github.com/sapphiredev/utilities/commit/688e39f26507a81fcf8be7c9e55d6290f38da460))
130
+ - **decorators:** add default messages to errors thrown by `RequiresPermissions` ([13d89a3](https://github.com/sapphiredev/utilities/commit/13d89a3e4e37664e59d8a7b722df95786c5fdf1b))
131
+ - **decorators:** set minimum NodeJS to v14 ([46c0f68](https://github.com/sapphiredev/utilities/commit/46c0f68a4b4f8ec5cff221183a1a620954be84be))
132
+
133
+ ### BREAKING CHANGES
134
+
135
+ - **decorators:** `RequiresPermissions` has been renamed to `RequiresClientPermissions`
136
+ - **decorators:** enum entry `DecoratorIdentifiers.RequiresPermissionsGuildOnly` has been changed to `DecoratorIdentifiers.RequiresClientPermissionsGuildOnly`
137
+ - **decorators:** enum entry `DecoratorIdentifiers.RequiresPermissionsMissingPermissions` has been changed to `DecoratorIdentifiers.RequiresClientPermissionsMissingPermissions`
138
+ - **decorators:** i18n identifier `requiresPermissionsGuildOnly` has been changed to `requiresClientPermissionsGuildOnly`
139
+ - **decorators:** i18n identifier `requiresPermissionsMissingPermissions` has been changed to `requiresClientPermissionsMissingPermissions`
140
+
141
+ # [2.2.0](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@2.1.5...@sapphire/decorators@2.2.0) (2021-07-20)
142
+
143
+ ### Features
144
+
145
+ - **decorators:** add new permission decorators ([#138](https://github.com/sapphiredev/utilities/issues/138)) ([60ab0ca](https://github.com/sapphiredev/utilities/commit/60ab0cabcc768950909b0a35c2924edff13cec0e))
146
+
147
+ ## [2.1.5](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@2.1.4...@sapphire/decorators@2.1.5) (2021-06-27)
148
+
149
+ **Note:** Version bump only for package @sapphire/decorators
150
+
151
+ ## [2.1.4](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@2.1.3...@sapphire/decorators@2.1.4) (2021-06-19)
152
+
153
+ ### Bug Fixes
154
+
155
+ - **docs:** update-tsdoc-for-vscode-may-2021 ([#126](https://github.com/sapphiredev/utilities/issues/126)) ([f8581bf](https://github.com/sapphiredev/utilities/commit/f8581bfe97a1b2f8aac3a3d3ed342d8ba92d730b))
156
+
157
+ ## [2.1.3](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@2.1.2...@sapphire/decorators@2.1.3) (2021-06-06)
158
+
159
+ ### Bug Fixes
160
+
161
+ - remove peer deps, update dev deps, update READMEs ([#124](https://github.com/sapphiredev/utilities/issues/124)) ([67256ed](https://github.com/sapphiredev/utilities/commit/67256ed43b915b02a8b5c68230ba82d6210c5032))
162
+
163
+ ## [2.1.2](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@2.1.1...@sapphire/decorators@2.1.2) (2021-05-20)
164
+
165
+ ### Bug Fixes
166
+
167
+ - **decorators:** mark package as side effect free ([d42dadf](https://github.com/sapphiredev/utilities/commit/d42dadfbc76cf6613479e03f1216d35fc247af30))
168
+
169
+ ## [2.1.1](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@2.1.0...@sapphire/decorators@2.1.1) (2021-05-02)
170
+
171
+ ### Bug Fixes
172
+
173
+ - drop the `www.` from the SapphireJS URL ([494d89f](https://github.com/sapphiredev/utilities/commit/494d89ffa04f78c195b93d7905b3232884f7d7e2))
174
+ - update all the SapphireJS URLs from `.com` to `.dev` ([f59b46d](https://github.com/sapphiredev/utilities/commit/f59b46d1a0ebd39cad17b17d71cd3b9da808d5fd))
175
+
176
+ # [2.1.0](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@2.0.10...@sapphire/decorators@2.1.0) (2021-04-21)
177
+
178
+ ### Features
179
+
180
+ - add @sapphire/embed-jsx ([#100](https://github.com/sapphiredev/utilities/issues/100)) ([7277a23](https://github.com/sapphiredev/utilities/commit/7277a236015236ed8e81b7882875410facc4ce17))
181
+
182
+ ## [2.0.10](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@2.0.9...@sapphire/decorators@2.0.10) (2021-04-19)
183
+
184
+ ### Bug Fixes
185
+
186
+ - change all Sapphire URLs from "project"->"community" & use our domain where applicable 👨‍🌾🚜 ([#102](https://github.com/sapphiredev/utilities/issues/102)) ([835b408](https://github.com/sapphiredev/utilities/commit/835b408e8e57130c3787aca2e32613346ff23e4d))
187
+
188
+ ## [2.0.9](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@2.0.8...@sapphire/decorators@2.0.9) (2021-04-03)
189
+
190
+ **Note:** Version bump only for package @sapphire/decorators
191
+
192
+ ## [2.0.8](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@2.0.7...@sapphire/decorators@2.0.8) (2021-03-16)
193
+
194
+ ### Bug Fixes
195
+
196
+ - **decorators:** bump framework dependency to v1.0.0 ([33dc61d](https://github.com/sapphiredev/utilities/commit/33dc61d9d0455cbe2f1385728fb8a2dd425dcc2a))
197
+
198
+ ## [2.0.7](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@2.0.6...@sapphire/decorators@2.0.7) (2021-03-16)
199
+
200
+ ### Bug Fixes
201
+
202
+ - **decorators:** add tslib dependency ([3085f1d](https://github.com/sapphiredev/utilities/commit/3085f1dadcd84fc8f7aa9c39a7f23333c1d4eb14))
203
+
204
+ ## [2.0.6](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@2.0.5...@sapphire/decorators@2.0.6) (2021-03-16)
205
+
206
+ **Note:** Version bump only for package @sapphire/decorators
207
+
208
+ ## [2.0.5](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@2.0.4...@sapphire/decorators@2.0.5) (2021-02-22)
209
+
210
+ ### Bug Fixes
211
+
212
+ - **decorators:** clean up required peer dependencies ([b29e8a7](https://github.com/sapphiredev/utilities/commit/b29e8a7c2adb7c6beff392291fd5f2bc8587271c))
213
+
214
+ ## [2.0.4](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@2.0.3...@sapphire/decorators@2.0.4) (2021-02-16)
215
+
216
+ **Note:** Version bump only for package @sapphire/decorators
217
+
218
+ ## [2.0.3](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@2.0.2...@sapphire/decorators@2.0.3) (2021-01-18)
219
+
220
+ ### Bug Fixes
221
+
222
+ - **decorators:** change `ApplyOptions`'s callback parameter from Client to PieceContext ([#61](https://github.com/sapphiredev/utilities/issues/61)) ([d8b916b](https://github.com/sapphiredev/utilities/commit/d8b916bb0f90b40499f7d6315bfec3cfd6642968))
223
+
224
+ ## [2.0.2](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@2.0.1...@sapphire/decorators@2.0.2) (2021-01-16)
225
+
226
+ **Note:** Version bump only for package @sapphire/decorators
227
+
228
+ ## [2.0.1](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@2.0.0...@sapphire/decorators@2.0.1) (2021-01-09)
229
+
230
+ ### Bug Fixes
231
+
232
+ - **decorators:** assign proper homepage url in package ([495fffc](https://github.com/sapphiredev/utilities/commit/495fffc3424335bd481ba684c29b2193194f2545))
233
+
234
+ # [2.0.0](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@1.2.1...@sapphire/decorators@2.0.0) (2021-01-08)
235
+
236
+ ### Features
237
+
238
+ - **{ts,eslint}-config,decorators:** remove TypeScript v3 from peer dependencies ([a211f0b](https://github.com/sapphiredev/utilities/commit/a211f0b1d07c634cf80701a6685537c14e35586e))
239
+
240
+ ### BREAKING CHANGES
241
+
242
+ - **{ts,eslint}-config,decorators:** TypeScript v3 removed from peer dependencies, it may still work, however we
243
+ strongly recommend updating.
244
+
245
+ ## [1.2.1](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@1.2.0...@sapphire/decorators@1.2.1) (2021-01-01)
246
+
247
+ **Note:** Version bump only for package @sapphire/decorators
248
+
249
+ # [1.2.0](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@1.1.0...@sapphire/decorators@1.2.0) (2020-12-26)
250
+
251
+ ### Bug Fixes
252
+
253
+ - **utilities,time-utilities:** set published versions of dependencies in peerDependencies ([adee6fc](https://github.com/sapphiredev/utilities/commit/adee6fcbd1f7d85e5abee2630aeaa3a192e2a29f))
254
+
255
+ ### Features
256
+
257
+ - **decorators:** add createFunctionPrecondition, fixed build ([#51](https://github.com/sapphiredev/utilities/issues/51)) ([c87d5db](https://github.com/sapphiredev/utilities/commit/c87d5db8e29bbfcf96a29e34e4e4186426bac304))
258
+
259
+ # [1.1.0](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@1.0.3...@sapphire/decorators@1.1.0) (2020-12-22)
260
+
261
+ ### Features
262
+
263
+ - added time-utilities package ([#26](https://github.com/sapphiredev/utilities/issues/26)) ([f17a333](https://github.com/sapphiredev/utilities/commit/f17a3339667a452e8745fad7884272176e5d65e8))
264
+
265
+ ## [1.0.3](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@1.0.2...@sapphire/decorators@1.0.3) (2020-11-04)
266
+
267
+ ### Bug Fixes
268
+
269
+ - **decorators:** properly specify ESM and CommonJS exports ([8bf3ec7](https://github.com/sapphiredev/utilities/commit/8bf3ec7a025574244e232fae93f31e67b1689cf9))
270
+
271
+ ## [1.0.2](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@1.0.1...@sapphire/decorators@1.0.2) (2020-10-11)
272
+
273
+ **Note:** Version bump only for package @sapphire/decorators
274
+
275
+ ## [1.0.1](https://github.com/sapphiredev/utilities/compare/@sapphire/decorators@1.0.0...@sapphire/decorators@1.0.1) (2020-09-20)
276
+
277
+ **Note:** Version bump only for package @sapphire/decorators
278
+
279
+ # 1.0.0 (2020-09-05)
280
+
281
+ ### Features
282
+
283
+ - **decorators:** add enumerableMethod decorator ([aa60625](https://github.com/sapphiredev/utilities/commit/aa606251336eb983e7a37e10bc69bb2ba232683a))
284
+ - implement snowflake ([5ba4e2d](https://github.com/sapphiredev/utilities/commit/5ba4e2d82557dd4ff60ffe891a7b46e46373bea2))
285
+ - **decorators:** add decorators package ([#4](https://github.com/sapphiredev/utilities/issues/4)) ([677b3e5](https://github.com/sapphiredev/utilities/commit/677b3e59d5c6160cbe6fb410821cadd7c0f00e3c))
286
+ - **decorators:** add enumerable decorator ([cbdd445](https://github.com/sapphiredev/utilities/commit/cbdd445dbe9341691ed706357bbcdd8636078a1b))
287
+
288
+ # Changelog
289
+
290
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
291
+
292
+ ## [2.3.0](https://github.com/skyra-project/decorators/compare/v2.2.0...v2.3.0) (2020-07-26)
293
+
294
+ ### Features
295
+
296
+ - rename master branch to main ([ea05734](https://github.com/skyra-project/decorators/commit/ea05734f32db0ea475e699e27658fb2749b40d5f))
297
+
298
+ ## [2.2.0](https://github.com/skyra-project/decorators/compare/v2.1.2...v2.2.0) (2020-07-02)
299
+
300
+ ### Features
301
+
302
+ - allow ApplyOptions to take a function ([#24](https://github.com/skyra-project/decorators/issues/24)) ([cbcabdc](https://github.com/skyra-project/decorators/commit/cbcabdc03cb937364cde72a3d4d393cfbf474e55))
303
+ - **apply-options:** add extendables support ([#26](https://github.com/skyra-project/decorators/issues/26)) ([39421bb](https://github.com/skyra-project/decorators/commit/39421bb69042a75d2b0257c6726436f432448281))
304
+
305
+ ### [2.1.2](https://github.com/skyra-project/decorators/compare/v2.1.1...v2.1.2) (2020-06-14)
306
+
307
+ ### Bug Fixes
308
+
309
+ - **core:** properly pass rest options for ApplyOptions ([e7c68d2](https://github.com/skyra-project/decorators/commit/e7c68d2613c16a4438b9a816a71d0c20de71cac5))
310
+
311
+ ### [2.1.1](https://github.com/skyra-project/decorators/compare/v2.1.0...v2.1.1) (2020-06-14)
312
+
313
+ ### Bug Fixes
314
+
315
+ - remove unnecessary optional chain ([bd7f3ec](https://github.com/skyra-project/decorators/commit/bd7f3ec347edd57c681b2283425569f3df4b5f32))
316
+
317
+ ## [2.1.0](https://github.com/skyra-project/decorators/compare/v2.0.0...v2.1.0) (2020-06-13)
318
+
319
+ ### Features
320
+
321
+ - add CreateResolvers & requiredPermissions decorators ([3bdc4bd](https://github.com/skyra-project/decorators/commit/3bdc4bd4066a1e1112307c15c69fc80c790584f0))
322
+
323
+ ## [2.0.0](https://github.com/skyra-project/decorators/compare/v1.0.0...v2.0.0) (2020-05-30)
324
+
325
+ ### ⚠ BREAKING CHANGES
326
+
327
+ - NodeJS version 12 is no longer supported. Install NodeJS 14 or higher.
328
+ - Discord.JS is no longer supported. This library now targets @klasa/core and the new
329
+ klasa
330
+
331
+ ### Features
332
+
333
+ - rework to using @klasa/core and the new klasa ([5100e86](https://github.com/skyra-project/decorators/commit/5100e869bc11e932350f97846942a8eb7b141c37))
334
+
335
+ ### Bug Fixes
336
+
337
+ - target NodeJS version 14 and higher ([a678765](https://github.com/skyra-project/decorators/commit/a678765ff28c2d16e12489512ac1d3d0d79e10fb))
338
+
339
+ ## 1.0.0 (2020-03-01)
340
+
341
+ ### Features
342
+
343
+ - add ApplyOptions + move to Jest ([#19](https://github.com/skyra-project/decorators/issues/19)) ([972e164](https://github.com/skyra-project/decorators/commit/972e164a40b5bb6f1296ea8a3d1f8312a3c8de23))
344
+ - update license ([d2366be](https://github.com/skyra-project/decorators/commit/d2366be6207c3794858d7255274b4c83fe14503d))
package/README.md CHANGED
@@ -93,6 +93,11 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
93
93
  </tr>
94
94
  <tr>
95
95
  <td align="center"><a href="https://c43721.dev/"><img src="https://avatars.githubusercontent.com/u/55610086?v=4?s=100" width="100px;" alt=""/><br /><sub><b>c43721</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=c43721" title="Code">💻</a></td>
96
+ <td align="center"><a href="https://commandtechno.com/"><img src="https://avatars.githubusercontent.com/u/68407783?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Commandtechno</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Commandtechno" title="Code">💻</a></td>
97
+ <td align="center"><a href="https://github.com/dhruv-kaushikk"><img src="https://avatars.githubusercontent.com/u/73697546?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aura</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=dhruv-kaushikk" title="Code">💻</a></td>
98
+ <td align="center"><a href="https://axis.moe/"><img src="https://avatars.githubusercontent.com/u/54381371?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jonathan</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=axisiscool" title="Code">💻</a></td>
99
+ <td align="center"><a href="https://github.com/imranbarbhuiya"><img src="https://avatars.githubusercontent.com/u/74945038?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Parbez</b></sub></a><br /><a href="#maintenance-imranbarbhuiya" title="Maintenance">🚧</a></td>
100
+ <td align="center"><a href="https://github.com/NotKaskus"><img src="https://avatars.githubusercontent.com/u/75168528?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Paul Andrew</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=NotKaskus" title="Documentation">📖</a></td>
96
101
  </tr>
97
102
  </table>
98
103
 
package/dist/index.js CHANGED
@@ -40,9 +40,11 @@ module.exports = __toCommonJS(src_exports);
40
40
  function createMethodDecorator(fn) {
41
41
  return fn;
42
42
  }
43
+ __name(createMethodDecorator, "createMethodDecorator");
43
44
  function createClassDecorator(fn) {
44
45
  return fn;
45
46
  }
47
+ __name(createClassDecorator, "createClassDecorator");
46
48
  function createFunctionPrecondition(precondition, fallback = () => void 0) {
47
49
  return createMethodDecorator((_target, _propertyKey, descriptor) => {
48
50
  const method = descriptor.value;
@@ -50,12 +52,13 @@ function createFunctionPrecondition(precondition, fallback = () => void 0) {
50
52
  throw new Error("Function preconditions require a [[value]].");
51
53
  if (typeof method !== "function")
52
54
  throw new Error("Function preconditions can only be applied to functions.");
53
- descriptor.value = async function descriptorValue(...args) {
55
+ descriptor.value = /* @__PURE__ */ __name(async function descriptorValue(...args) {
54
56
  const canRun = await precondition(...args);
55
57
  return canRun ? method.call(this, ...args) : fallback.call(this, ...args);
56
- };
58
+ }, "descriptorValue");
57
59
  });
58
60
  }
61
+ __name(createFunctionPrecondition, "createFunctionPrecondition");
59
62
  function createProxy(target, handler) {
60
63
  return new Proxy(target, {
61
64
  ...handler,
@@ -65,6 +68,7 @@ function createProxy(target, handler) {
65
68
  }
66
69
  });
67
70
  }
71
+ __name(createProxy, "createProxy");
68
72
 
69
73
  // src/base-decorators.ts
70
74
  function Enumerable(value) {
@@ -82,11 +86,13 @@ function Enumerable(value) {
82
86
  });
83
87
  };
84
88
  }
89
+ __name(Enumerable, "Enumerable");
85
90
  function EnumerableMethod(value) {
86
91
  return createMethodDecorator((_target, _propertyKey, descriptor) => {
87
92
  descriptor.enumerable = value;
88
93
  });
89
94
  }
95
+ __name(EnumerableMethod, "EnumerableMethod");
90
96
 
91
97
  // src/djs-decorators.ts
92
98
  var import_discord = require("@sapphire/discord.js-utilities");
@@ -172,9 +178,11 @@ var RequiresUserPermissions = /* @__PURE__ */ __name((...permissionsResolvable)
172
178
  function RequiresGuildContext(fallback = () => void 0) {
173
179
  return createFunctionPrecondition((message) => message.guild !== null, fallback);
174
180
  }
181
+ __name(RequiresGuildContext, "RequiresGuildContext");
175
182
  function RequiresDMContext(fallback = () => void 0) {
176
183
  return createFunctionPrecondition((message) => message.guild === null, fallback);
177
184
  }
185
+ __name(RequiresDMContext, "RequiresDMContext");
178
186
 
179
187
  // src/piece-decorators.ts
180
188
  var import_framework2 = require("@sapphire/framework");
@@ -186,6 +194,7 @@ function ApplyOptions(optionsOrFn) {
186
194
  })
187
195
  }));
188
196
  }
197
+ __name(ApplyOptions, "ApplyOptions");
189
198
  // Annotate the CommonJS export names for ESM import in node:
190
199
  0 && (module.exports = {
191
200
  ApplyOptions,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/utils.ts","../src/base-decorators.ts","../src/djs-decorators.ts","../src/piece-decorators.ts"],"sourcesContent":["export * from './base-decorators';\nexport * from './djs-decorators';\nexport * from './piece-decorators';\nexport * from './utils';\n","/**\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 */\n// eslint-disable-next-line @typescript-eslint/ban-types\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 { Message, PermissionResolvable, Permissions } from 'discord.js';\nimport { createFunctionPrecondition, FunctionFallback } from './utils';\n\nexport const enum DecoratorIdentifiers {\n\tRequiresClientPermissionsGuildOnly = 'requiresClientPermissionsGuildOnly',\n\tRequiresClientPermissionsMissingPermissions = 'requiresClientPermissionsMissingPermissions',\n\tRequiresUserPermissionsGuildOnly = 'requiresUserPermissionsGuildOnly',\n\tRequiresUserPermissionsMissingPermissions = 'requiresUserPermissionsMissingPermissions'\n}\n\nconst DMAvailablePermissions = new Permissions(\n\t~new Permissions([\n\t\t//\n\t\t'ADD_REACTIONS',\n\t\t'ATTACH_FILES',\n\t\t'EMBED_LINKS',\n\t\t'READ_MESSAGE_HISTORY',\n\t\t'SEND_MESSAGES',\n\t\t'USE_EXTERNAL_EMOJIS',\n\t\t'VIEW_CHANNEL'\n\t]).bitfield & Permissions.ALL\n);\n\nconst DMAvailableUserPermissions = new Permissions(\n\t~new Permissions([\n\t\t'ADD_REACTIONS',\n\t\t'ATTACH_FILES',\n\t\t'EMBED_LINKS',\n\t\t'READ_MESSAGE_HISTORY',\n\t\t'SEND_MESSAGES',\n\t\t'USE_EXTERNAL_EMOJIS',\n\t\t'VIEW_CHANNEL',\n\t\t'USE_EXTERNAL_STICKERS',\n\t\t'MENTION_EVERYONE'\n\t]).bitfield & Permissions.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 { SubCommandPluginCommand, SubCommandPluginCommandOptions } from '@sapphire/plugin-subcommands';\n * import type { Message } from 'discord.js';\n *\n * (at)ApplyOptions<SubCommandPluginCommandOptions>({\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 SubCommandPluginCommand {\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 Permissions(permissionsResolvable);\n\tconst resolvedIncludesServerPermissions = Boolean(resolved.bitfield & DMAvailablePermissions.bitfield);\n\n\treturn createFunctionPrecondition((message: Message) => {\n\t\tif (resolvedIncludesServerPermissions && isDMChannel(message.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(message.channel)) {\n\t\t\tconst missingPermissions = message.channel.permissionsFor(message.guild!.me!).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 { SubCommandPluginCommand, SubCommandPluginCommandOptions } from '@sapphire/plugin-subcommands';\n * import type { Message } from 'discord.js';\n *\n * (at)ApplyOptions<SubCommandPluginCommandOptions>({\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 SubCommandPluginCommand {\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 Permissions(permissionsResolvable);\n\tconst resolvedIncludesServerPermissions = Boolean(resolved.bitfield & DMAvailableUserPermissions.bitfield);\n\n\treturn createFunctionPrecondition((message: Message) => {\n\t\tif (resolvedIncludesServerPermissions && isDMChannel(message.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(message.channel)) {\n\t\t\tconst missingPermissions = message.channel.permissionsFor(message.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 `Message` instance\n * @since 1.0.0\n * @param fallback The fallback value passed to `createFunctionInhibitor`\n */\nexport function RequiresGuildContext(fallback: FunctionFallback = (): void => undefined): MethodDecorator {\n\treturn createFunctionPrecondition((message: Message) => message.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 `Message` instance\n * @since 1.0.0\n * @param fallback The fallback value passed to `createFunctionInhibitor`\n */\nexport function RequiresDMContext(fallback: FunctionFallback = (): void => undefined): MethodDecorator {\n\treturn createFunctionPrecondition((message: Message) => message.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-api-types/v9';\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiCO,+BAA+B,IAAsC;AAC3E,SAAO;AACR;AAFgB,AAST,8BAA0E,IAA+B;AAC/G,SAAO;AACR;AAFgB,AA8BT,oCAAoC,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,kCAAiE,MAAa;AAChG,YAAM,SAAS,MAAM,aAAa,GAAG,IAAI;AACzC,aAAO,SAAS,OAAO,KAAK,MAAM,GAAG,IAAI,IAAI,SAAS,KAAK,MAAM,GAAG,IAAI;AAAA,IACzE;AAAA,EACD,CAAC;AACF;AAXgB,AAoBT,qBAAuC,QAAW,SAA0C;AAClG,SAAO,IAAI,MAAM,QAAQ;AAAA,OACrB;AAAA,IACH,KAAK,CAAC,SAAQ,aAAa;AAC1B,YAA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MAAM,QAAQ;AACzF;AAFgB,AAST,2BAA2B,WAA6B,MAAY,QAA4B;AACtG,SAAO,2BAA2B,CAAC,YAAqB,QAAQ,UAAU,MAAM,QAAQ;AACzF;AAFgB;;AC/LhB,wBAAsC;AAmD/B,sBAA+C,aAAsF;AAC3I,SAAO,qBAAqB,CAAC,WAC5B,YAAY,QAAQ;AAAA,IACnB,WAAW,CAAC,MAAM,CAAC,SAAS,cAAc,CAAC,OAC1C,IAAI,KAAK,SAAS;AAAA,SACd;AAAA,SACC,OAAO,gBAAgB,aAAa,YAAY,EAAE,wCAAW,QAAQ,CAAC,IAAI;AAAA,IAC/E,CAAC;AAAA,EACH,CAAC,CACF;AACD;AAVgB","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/utils.ts","../src/base-decorators.ts","../src/djs-decorators.ts","../src/piece-decorators.ts"],"sourcesContent":["export * from './base-decorators';\nexport * from './djs-decorators';\nexport * from './piece-decorators';\nexport * from './utils';\n","/**\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 */\n// eslint-disable-next-line @typescript-eslint/ban-types\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 { Message, PermissionResolvable, Permissions } from 'discord.js';\nimport { createFunctionPrecondition, FunctionFallback } from './utils';\n\nexport const enum DecoratorIdentifiers {\n\tRequiresClientPermissionsGuildOnly = 'requiresClientPermissionsGuildOnly',\n\tRequiresClientPermissionsMissingPermissions = 'requiresClientPermissionsMissingPermissions',\n\tRequiresUserPermissionsGuildOnly = 'requiresUserPermissionsGuildOnly',\n\tRequiresUserPermissionsMissingPermissions = 'requiresUserPermissionsMissingPermissions'\n}\n\nconst DMAvailablePermissions = new Permissions(\n\t~new Permissions([\n\t\t//\n\t\t'ADD_REACTIONS',\n\t\t'ATTACH_FILES',\n\t\t'EMBED_LINKS',\n\t\t'READ_MESSAGE_HISTORY',\n\t\t'SEND_MESSAGES',\n\t\t'USE_EXTERNAL_EMOJIS',\n\t\t'VIEW_CHANNEL'\n\t]).bitfield & Permissions.ALL\n);\n\nconst DMAvailableUserPermissions = new Permissions(\n\t~new Permissions([\n\t\t'ADD_REACTIONS',\n\t\t'ATTACH_FILES',\n\t\t'EMBED_LINKS',\n\t\t'READ_MESSAGE_HISTORY',\n\t\t'SEND_MESSAGES',\n\t\t'USE_EXTERNAL_EMOJIS',\n\t\t'VIEW_CHANNEL',\n\t\t'USE_EXTERNAL_STICKERS',\n\t\t'MENTION_EVERYONE'\n\t]).bitfield & Permissions.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 { SubCommandPluginCommand, SubCommandPluginCommandOptions } from '@sapphire/plugin-subcommands';\n * import type { Message } from 'discord.js';\n *\n * (at)ApplyOptions<SubCommandPluginCommandOptions>({\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 SubCommandPluginCommand {\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 Permissions(permissionsResolvable);\n\tconst resolvedIncludesServerPermissions = Boolean(resolved.bitfield & DMAvailablePermissions.bitfield);\n\n\treturn createFunctionPrecondition((message: Message) => {\n\t\tif (resolvedIncludesServerPermissions && isDMChannel(message.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(message.channel)) {\n\t\t\tconst missingPermissions = message.channel.permissionsFor(message.guild!.me!).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 { SubCommandPluginCommand, SubCommandPluginCommandOptions } from '@sapphire/plugin-subcommands';\n * import type { Message } from 'discord.js';\n *\n * (at)ApplyOptions<SubCommandPluginCommandOptions>({\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 SubCommandPluginCommand {\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 Permissions(permissionsResolvable);\n\tconst resolvedIncludesServerPermissions = Boolean(resolved.bitfield & DMAvailableUserPermissions.bitfield);\n\n\treturn createFunctionPrecondition((message: Message) => {\n\t\tif (resolvedIncludesServerPermissions && isDMChannel(message.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(message.channel)) {\n\t\t\tconst missingPermissions = message.channel.permissionsFor(message.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 `Message` instance\n * @since 1.0.0\n * @param fallback The fallback value passed to `createFunctionInhibitor`\n */\nexport function RequiresGuildContext(fallback: FunctionFallback = (): void => undefined): MethodDecorator {\n\treturn createFunctionPrecondition((message: Message) => message.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 `Message` instance\n * @since 1.0.0\n * @param fallback The fallback value passed to `createFunctionInhibitor`\n */\nexport function RequiresDMContext(fallback: FunctionFallback = (): void => undefined): MethodDecorator {\n\treturn createFunctionPrecondition((message: Message) => message.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-api-types/v9';\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiCO,+BAA+B,IAAsC;AAC3E,SAAO;AACR;AAFgB;AAST,8BAA0E,IAA+B;AAC/G,SAAO;AACR;AAFgB;AA8BT,oCAAoC,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,yDAAiE,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;AAoBT,qBAAuC,QAAW,SAA0C;AAClG,SAAO,IAAI,MAAM,QAAQ;AAAA,OACrB;AAAA,IACH,KAAK,CAAC,SAAQ,aAAa;AAC1B,YAAM,QAAQ,QAAQ,IAAI,SAAQ,QAAQ;AAC1C,aAAO,OAAO,UAAU,aAAa,IAAI,SAA6B,MAAM,MAAM,SAAQ,IAAI,IAAI;AAAA,IACnG;AAAA,EACD,CAAC;AACF;AARgB;;;ACrFT,oBAAoB,OAAgB;AAC1C,SAAO,CAAC,QAAiB,QAAgB;AACxC,YAAQ,eAAe,QAAyB,KAAK;AAAA,MAC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AAM,CAAC,SAAS,cAAc,CAAC,OAC1C,IAAI,KAAK,SAAS;AAAA,SACd;AAAA,SACC,OAAO,gBAAgB,aAAa,YAAY,EAAE,wCAAW,QAAQ,CAAC,IAAI;AAAA,IAC/E,CAAC;AAAA,EACH,CAAC,CACF;AACD;AAVgB;","names":[]}
package/dist/index.mjs CHANGED
@@ -5,9 +5,11 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
5
5
  function createMethodDecorator(fn) {
6
6
  return fn;
7
7
  }
8
+ __name(createMethodDecorator, "createMethodDecorator");
8
9
  function createClassDecorator(fn) {
9
10
  return fn;
10
11
  }
12
+ __name(createClassDecorator, "createClassDecorator");
11
13
  function createFunctionPrecondition(precondition, fallback = () => void 0) {
12
14
  return createMethodDecorator((_target, _propertyKey, descriptor) => {
13
15
  const method = descriptor.value;
@@ -15,12 +17,13 @@ function createFunctionPrecondition(precondition, fallback = () => void 0) {
15
17
  throw new Error("Function preconditions require a [[value]].");
16
18
  if (typeof method !== "function")
17
19
  throw new Error("Function preconditions can only be applied to functions.");
18
- descriptor.value = async function descriptorValue(...args) {
20
+ descriptor.value = /* @__PURE__ */ __name(async function descriptorValue(...args) {
19
21
  const canRun = await precondition(...args);
20
22
  return canRun ? method.call(this, ...args) : fallback.call(this, ...args);
21
- };
23
+ }, "descriptorValue");
22
24
  });
23
25
  }
26
+ __name(createFunctionPrecondition, "createFunctionPrecondition");
24
27
  function createProxy(target, handler) {
25
28
  return new Proxy(target, {
26
29
  ...handler,
@@ -30,6 +33,7 @@ function createProxy(target, handler) {
30
33
  }
31
34
  });
32
35
  }
36
+ __name(createProxy, "createProxy");
33
37
 
34
38
  // src/base-decorators.ts
35
39
  function Enumerable(value) {
@@ -47,11 +51,13 @@ function Enumerable(value) {
47
51
  });
48
52
  };
49
53
  }
54
+ __name(Enumerable, "Enumerable");
50
55
  function EnumerableMethod(value) {
51
56
  return createMethodDecorator((_target, _propertyKey, descriptor) => {
52
57
  descriptor.enumerable = value;
53
58
  });
54
59
  }
60
+ __name(EnumerableMethod, "EnumerableMethod");
55
61
 
56
62
  // src/djs-decorators.ts
57
63
  import { isDMChannel, isGuildBasedChannel } from "@sapphire/discord.js-utilities";
@@ -137,9 +143,11 @@ var RequiresUserPermissions = /* @__PURE__ */ __name((...permissionsResolvable)
137
143
  function RequiresGuildContext(fallback = () => void 0) {
138
144
  return createFunctionPrecondition((message) => message.guild !== null, fallback);
139
145
  }
146
+ __name(RequiresGuildContext, "RequiresGuildContext");
140
147
  function RequiresDMContext(fallback = () => void 0) {
141
148
  return createFunctionPrecondition((message) => message.guild === null, fallback);
142
149
  }
150
+ __name(RequiresDMContext, "RequiresDMContext");
143
151
 
144
152
  // src/piece-decorators.ts
145
153
  import { container } from "@sapphire/framework";
@@ -151,6 +159,7 @@ function ApplyOptions(optionsOrFn) {
151
159
  })
152
160
  }));
153
161
  }
162
+ __name(ApplyOptions, "ApplyOptions");
154
163
  export {
155
164
  ApplyOptions,
156
165
  DecoratorIdentifiers,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils.ts","../src/base-decorators.ts","../src/djs-decorators.ts","../src/piece-decorators.ts"],"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 */\n// eslint-disable-next-line @typescript-eslint/ban-types\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 { Message, PermissionResolvable, Permissions } from 'discord.js';\nimport { createFunctionPrecondition, FunctionFallback } from './utils';\n\nexport const enum DecoratorIdentifiers {\n\tRequiresClientPermissionsGuildOnly = 'requiresClientPermissionsGuildOnly',\n\tRequiresClientPermissionsMissingPermissions = 'requiresClientPermissionsMissingPermissions',\n\tRequiresUserPermissionsGuildOnly = 'requiresUserPermissionsGuildOnly',\n\tRequiresUserPermissionsMissingPermissions = 'requiresUserPermissionsMissingPermissions'\n}\n\nconst DMAvailablePermissions = new Permissions(\n\t~new Permissions([\n\t\t//\n\t\t'ADD_REACTIONS',\n\t\t'ATTACH_FILES',\n\t\t'EMBED_LINKS',\n\t\t'READ_MESSAGE_HISTORY',\n\t\t'SEND_MESSAGES',\n\t\t'USE_EXTERNAL_EMOJIS',\n\t\t'VIEW_CHANNEL'\n\t]).bitfield & Permissions.ALL\n);\n\nconst DMAvailableUserPermissions = new Permissions(\n\t~new Permissions([\n\t\t'ADD_REACTIONS',\n\t\t'ATTACH_FILES',\n\t\t'EMBED_LINKS',\n\t\t'READ_MESSAGE_HISTORY',\n\t\t'SEND_MESSAGES',\n\t\t'USE_EXTERNAL_EMOJIS',\n\t\t'VIEW_CHANNEL',\n\t\t'USE_EXTERNAL_STICKERS',\n\t\t'MENTION_EVERYONE'\n\t]).bitfield & Permissions.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 { SubCommandPluginCommand, SubCommandPluginCommandOptions } from '@sapphire/plugin-subcommands';\n * import type { Message } from 'discord.js';\n *\n * (at)ApplyOptions<SubCommandPluginCommandOptions>({\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 SubCommandPluginCommand {\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 Permissions(permissionsResolvable);\n\tconst resolvedIncludesServerPermissions = Boolean(resolved.bitfield & DMAvailablePermissions.bitfield);\n\n\treturn createFunctionPrecondition((message: Message) => {\n\t\tif (resolvedIncludesServerPermissions && isDMChannel(message.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(message.channel)) {\n\t\t\tconst missingPermissions = message.channel.permissionsFor(message.guild!.me!).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 { SubCommandPluginCommand, SubCommandPluginCommandOptions } from '@sapphire/plugin-subcommands';\n * import type { Message } from 'discord.js';\n *\n * (at)ApplyOptions<SubCommandPluginCommandOptions>({\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 SubCommandPluginCommand {\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 Permissions(permissionsResolvable);\n\tconst resolvedIncludesServerPermissions = Boolean(resolved.bitfield & DMAvailableUserPermissions.bitfield);\n\n\treturn createFunctionPrecondition((message: Message) => {\n\t\tif (resolvedIncludesServerPermissions && isDMChannel(message.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(message.channel)) {\n\t\t\tconst missingPermissions = message.channel.permissionsFor(message.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 `Message` instance\n * @since 1.0.0\n * @param fallback The fallback value passed to `createFunctionInhibitor`\n */\nexport function RequiresGuildContext(fallback: FunctionFallback = (): void => undefined): MethodDecorator {\n\treturn createFunctionPrecondition((message: Message) => message.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 `Message` instance\n * @since 1.0.0\n * @param fallback The fallback value passed to `createFunctionInhibitor`\n */\nexport function RequiresDMContext(fallback: FunctionFallback = (): void => undefined): MethodDecorator {\n\treturn createFunctionPrecondition((message: Message) => message.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-api-types/v9';\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"],"mappings":";;;;AAiCO,+BAA+B,IAAsC;AAC3E,SAAO;AACR;AAFgB,AAST,8BAA0E,IAA+B;AAC/G,SAAO;AACR;AAFgB,AA8BT,oCAAoC,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,kCAAiE,MAAa;AAChG,YAAM,SAAS,MAAM,aAAa,GAAG,IAAI;AACzC,aAAO,SAAS,OAAO,KAAK,MAAM,GAAG,IAAI,IAAI,SAAS,KAAK,MAAM,GAAG,IAAI;AAAA,IACzE;AAAA,EACD,CAAC;AACF;AAXgB,AAoBT,qBAAuC,QAAW,SAA0C;AAClG,SAAO,IAAI,MAAM,QAAQ;AAAA,OACrB;AAAA,IACH,KAAK,CAAC,SAAQ,aAAa;AAC1B,YAAM,QAAQ,QAAQ,IAAI,SAAQ,QAAQ;AAC1C,aAAO,OAAO,UAAU,aAAa,IAAI,SAA6B,MAAM,MAAM,SAAQ,IAAI,IAAI;AAAA,IACnG;AAAA,EACD,CAAC;AACF;AARgB;;ACrFT,oBAAoB,OAAgB;AAC1C,SAAO,CAAC,QAAiB,QAAgB;AACxC,YAAQ,eAAe,QAAyB,KAAK;AAAA,MACpD,YAAY;AAAA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C,OAAO,gBAAgB,aAAa,YAAY,EAAE,WAAW,QAAQ,CAAC,IAAI;AAAA,IAC/E,CAAC;AAAA,EACH,CAAC,CACF;AACD;AAVgB","names":[]}
1
+ {"version":3,"sources":["../src/utils.ts","../src/base-decorators.ts","../src/djs-decorators.ts","../src/piece-decorators.ts"],"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 */\n// eslint-disable-next-line @typescript-eslint/ban-types\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 { Message, PermissionResolvable, Permissions } from 'discord.js';\nimport { createFunctionPrecondition, FunctionFallback } from './utils';\n\nexport const enum DecoratorIdentifiers {\n\tRequiresClientPermissionsGuildOnly = 'requiresClientPermissionsGuildOnly',\n\tRequiresClientPermissionsMissingPermissions = 'requiresClientPermissionsMissingPermissions',\n\tRequiresUserPermissionsGuildOnly = 'requiresUserPermissionsGuildOnly',\n\tRequiresUserPermissionsMissingPermissions = 'requiresUserPermissionsMissingPermissions'\n}\n\nconst DMAvailablePermissions = new Permissions(\n\t~new Permissions([\n\t\t//\n\t\t'ADD_REACTIONS',\n\t\t'ATTACH_FILES',\n\t\t'EMBED_LINKS',\n\t\t'READ_MESSAGE_HISTORY',\n\t\t'SEND_MESSAGES',\n\t\t'USE_EXTERNAL_EMOJIS',\n\t\t'VIEW_CHANNEL'\n\t]).bitfield & Permissions.ALL\n);\n\nconst DMAvailableUserPermissions = new Permissions(\n\t~new Permissions([\n\t\t'ADD_REACTIONS',\n\t\t'ATTACH_FILES',\n\t\t'EMBED_LINKS',\n\t\t'READ_MESSAGE_HISTORY',\n\t\t'SEND_MESSAGES',\n\t\t'USE_EXTERNAL_EMOJIS',\n\t\t'VIEW_CHANNEL',\n\t\t'USE_EXTERNAL_STICKERS',\n\t\t'MENTION_EVERYONE'\n\t]).bitfield & Permissions.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 { SubCommandPluginCommand, SubCommandPluginCommandOptions } from '@sapphire/plugin-subcommands';\n * import type { Message } from 'discord.js';\n *\n * (at)ApplyOptions<SubCommandPluginCommandOptions>({\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 SubCommandPluginCommand {\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 Permissions(permissionsResolvable);\n\tconst resolvedIncludesServerPermissions = Boolean(resolved.bitfield & DMAvailablePermissions.bitfield);\n\n\treturn createFunctionPrecondition((message: Message) => {\n\t\tif (resolvedIncludesServerPermissions && isDMChannel(message.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(message.channel)) {\n\t\t\tconst missingPermissions = message.channel.permissionsFor(message.guild!.me!).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 { SubCommandPluginCommand, SubCommandPluginCommandOptions } from '@sapphire/plugin-subcommands';\n * import type { Message } from 'discord.js';\n *\n * (at)ApplyOptions<SubCommandPluginCommandOptions>({\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 SubCommandPluginCommand {\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 Permissions(permissionsResolvable);\n\tconst resolvedIncludesServerPermissions = Boolean(resolved.bitfield & DMAvailableUserPermissions.bitfield);\n\n\treturn createFunctionPrecondition((message: Message) => {\n\t\tif (resolvedIncludesServerPermissions && isDMChannel(message.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(message.channel)) {\n\t\t\tconst missingPermissions = message.channel.permissionsFor(message.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 `Message` instance\n * @since 1.0.0\n * @param fallback The fallback value passed to `createFunctionInhibitor`\n */\nexport function RequiresGuildContext(fallback: FunctionFallback = (): void => undefined): MethodDecorator {\n\treturn createFunctionPrecondition((message: Message) => message.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 `Message` instance\n * @since 1.0.0\n * @param fallback The fallback value passed to `createFunctionInhibitor`\n */\nexport function RequiresDMContext(fallback: FunctionFallback = (): void => undefined): MethodDecorator {\n\treturn createFunctionPrecondition((message: Message) => message.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-api-types/v9';\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"],"mappings":";;;;AAiCO,+BAA+B,IAAsC;AAC3E,SAAO;AACR;AAFgB;AAST,8BAA0E,IAA+B;AAC/G,SAAO;AACR;AAFgB;AA8BT,oCAAoC,cAAoC,WAA6B,MAAY,QAA4B;AACnJ,SAAO,sBAAsB,CAAC,SAAS,cAAc,eAAe;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AEA,QAAI,oBAAoB,QAAQ,OAAO,GAAG;AACzC,YAAM,qBAAqB,QAAQ,QAAQ,eAAe,QAAQ,MAAO,EAAE,QAAQ,QAAQ;AAE3F,UAAI,mBAAmB,QAAQ;AAC9B,cAAM,IAAI,UAAU;AAAA,UACnB,YAAY;AAAA,UACZ,SAAS,+EAA+E;AAAA,UACxF,SAAS;AAAA,YACR,SAAS;AAAA,UACV;AAAA,QACD,CAAC;AAAA,MACF;AAAA,IACD;AAEA,WAAO;AAAA,EACR,CAAC;AACF,GA5BuC;AAmChC,8BAA8B,WAA6B,MAAY,QAA4B;AACzG,SAAO,2BAA2B,CAAC,YAAqB,QAAQ,UAAU,MAAM,QAAQ;AACzF;AAFgB;AAST,2BAA2B,WAA6B,MAAY,QAA4B;AACtG,SAAO,2BAA2B,CAAC,YAAqB,QAAQ,UAAU,MAAM,QAAQ;AACzF;AAFgB;;;AC/LhB;AAmDO,sBAA+C,aAAsF;AAC3I,SAAO,qBAAqB,CAAC,WAC5B,YAAY,QAAQ;AAAA,IACnB,WAAW,CAAC,MAAM,CAAC,SAAS,cAAc,CAAC,OAC1C,IAAI,KAAK,SAAS;AAAA,SACd;AAAA,SACC,OAAO,gBAAgB,aAAa,YAAY,EAAE,WAAW,QAAQ,CAAC,IAAI;AAAA,IAC/E,CAAC;AAAA,EACH,CAAC,CACF;AACD;AAVgB;","names":[]}
package/package.json CHANGED
@@ -1,62 +1,65 @@
1
1
  {
2
- "name": "@sapphire/decorators",
3
- "version": "4.3.4",
4
- "description": "Useful TypeScript decorators for Sapphire Framework Discord bots",
5
- "author": "@sapphire",
6
- "license": "MIT",
7
- "main": "dist/index.js",
8
- "types": "dist/index.d.ts",
9
- "typedocMain": "src/index.ts",
10
- "exports": {
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js",
13
- "types": "./dist/index.d.ts"
14
- },
15
- "sideEffects": false,
16
- "homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/decorators",
17
- "scripts": {
18
- "test": "jest",
19
- "lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
20
- "build": "tsup && tsc -b src",
21
- "prepublishOnly": "yarn build"
22
- },
23
- "dependencies": {
24
- "tslib": "^2.3.1"
25
- },
26
- "devDependencies": {
27
- "@sapphire/discord-utilities": "^2.10.3",
28
- "@sapphire/discord.js-utilities": "^4.9.4",
29
- "@sapphire/ratelimits": "^2.4.4",
30
- "@sapphire/utilities": "^3.6.2"
31
- },
32
- "repository": {
33
- "type": "git",
34
- "url": "git+https://github.com/sapphiredev/utilities.git",
35
- "directory": "packages/decorators"
36
- },
37
- "files": [
38
- "dist",
39
- "!dist/*.tsbuildinfo"
40
- ],
41
- "engines": {
42
- "node": ">=v14.0.0",
43
- "npm": ">=7.0.0"
44
- },
45
- "keywords": [
46
- "sapphiredev",
47
- "bot",
48
- "typescript",
49
- "ts",
50
- "yarn",
51
- "discord",
52
- "sapphire",
53
- "standalone"
54
- ],
55
- "bugs": {
56
- "url": "https://github.com/sapphiredev/utilities/issues"
57
- },
58
- "publishConfig": {
59
- "access": "public"
60
- },
61
- "gitHead": "bf5ac56e547bfdbfac38e020882004e0f136546e"
62
- }
2
+ "name": "@sapphire/decorators",
3
+ "version": "4.3.5-next.00da8f1.0",
4
+ "description": "Useful TypeScript decorators for Sapphire Framework Discord bots",
5
+ "author": "@sapphire",
6
+ "license": "MIT",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ },
14
+ "sideEffects": false,
15
+ "homepage": "https://github.com/sapphiredev/utilities/tree/main/packages/decorators",
16
+ "scripts": {
17
+ "test": "jest",
18
+ "lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
19
+ "build": "tsup && tsc -b src",
20
+ "prepublish": "yarn build",
21
+ "bump": "cliff-jumper",
22
+ "check-update": "cliff-jumper --dry-run"
23
+ },
24
+ "dependencies": {
25
+ "tslib": "^2.3.1"
26
+ },
27
+ "devDependencies": {
28
+ "@sapphire/discord-utilities": "^2.10.4-next.00da8f1.0",
29
+ "@sapphire/discord.js-utilities": "^4.9.5-next.00da8f1.0",
30
+ "@sapphire/ratelimits": "^2.4.5-next.00da8f1.0",
31
+ "@sapphire/utilities": "^3.6.3-next.00da8f1.0",
32
+ "tsup": "^5.12.5",
33
+ "typescript": "^4.6.3"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/sapphiredev/utilities.git",
38
+ "directory": "packages/decorators"
39
+ },
40
+ "files": [
41
+ "dist/**/*.js*",
42
+ "dist/**/*.mjs*",
43
+ "dist/**/*.d*"
44
+ ],
45
+ "engines": {
46
+ "node": ">=v14.0.0",
47
+ "npm": ">=7.0.0"
48
+ },
49
+ "keywords": [
50
+ "sapphiredev",
51
+ "bot",
52
+ "typescript",
53
+ "ts",
54
+ "yarn",
55
+ "discord",
56
+ "sapphire",
57
+ "standalone"
58
+ ],
59
+ "bugs": {
60
+ "url": "https://github.com/sapphiredev/utilities/issues"
61
+ },
62
+ "publishConfig": {
63
+ "access": "public"
64
+ }
65
+ }
package/LICENSE.md DELETED
@@ -1,24 +0,0 @@
1
- # The MIT License (MIT)
2
-
3
- Copyright © `2020` `The Sapphire Community and its contributors`
4
-
5
- Permission is hereby granted, free of charge, to any person
6
- obtaining a copy of this software and associated documentation
7
- files (the “Software”), to deal in the Software without
8
- restriction, including without limitation the rights to use,
9
- copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the
11
- Software is furnished to do so, subject to the following
12
- conditions:
13
-
14
- The above copyright notice and this permission notice shall be
15
- included in all copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
18
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
- OTHER DEALINGS IN THE SOFTWARE.