@@ -15,6 +15,20 @@ export const Target = createParamDecorator((_, context) => {
15
15
: interaction . options . getUser ( 'user' ) ;
16
16
} ) ;
17
17
18
+ /**
19
+ * Decorator that injects the target message of a message context menu command.
20
+ * @see TargetUser
21
+ * @see TargetMember
22
+ * @see MessageCommand
23
+ * @returns The target message.
24
+ * @example
25
+ * ```ts
26
+ * @MessageCommand ({ name: 'quote', type: 'MESSAGE' })
27
+ * public async quote(@TargetMessage() message: Message) {
28
+ * message.reply('Quoting...');
29
+ * }
30
+ * ```
31
+ */
18
32
export const TargetMessage = createParamDecorator ( ( _ , context ) => {
19
33
const necordContext = NecordExecutionContext . create ( context ) ;
20
34
const [ interaction ] = necordContext . getContext < 'interactionCreate' > ( ) ;
@@ -24,6 +38,20 @@ export const TargetMessage = createParamDecorator((_, context) => {
24
38
return interaction . targetMessage ;
25
39
} ) ;
26
40
41
+ /**
42
+ * Decorator that injects the target user of a user context menu command.
43
+ * @see TargetMessage
44
+ * @see TargetMember
45
+ * @see UserCommand
46
+ * @returns The target user.
47
+ * @example
48
+ * ```ts
49
+ * @UserCommand ({ name: 'kick', type: 'USER' })
50
+ * public async avatar(@TargetUser() user: User) {
51
+ * user.avatarURL();
52
+ * }
53
+ * ```
54
+ */
27
55
export const TargetUser = createParamDecorator ( ( _ , context ) => {
28
56
const necordContext = NecordExecutionContext . create ( context ) ;
29
57
const [ interaction ] = necordContext . getContext < 'interactionCreate' > ( ) ;
@@ -33,6 +61,20 @@ export const TargetUser = createParamDecorator((_, context) => {
33
61
return interaction . targetUser ;
34
62
} ) ;
35
63
64
+ /**
65
+ * Decorator that injects the target member of a user context menu command.
66
+ * @see TargetMessage
67
+ * @see TargetUser
68
+ * @see UserCommand
69
+ * @returns The target member.
70
+ * @example
71
+ * ```ts
72
+ * @UserCommand ({ name: 'ban', type: 'USER' })
73
+ * public async ban(@TargetMember() member: GuildMember) {
74
+ * member.ban();
75
+ * }
76
+ * ```
77
+ */
36
78
export const TargetMember = createParamDecorator ( ( _ , context ) => {
37
79
const necordContext = NecordExecutionContext . create ( context ) ;
38
80
const [ interaction ] = necordContext . getContext < 'interactionCreate' > ( ) ;
0 commit comments