@pikokr/command.ts 3.2.4-dev.434c22e → 4.0.0-dev.fddc66b

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.
Files changed (182) hide show
  1. package/dist/applicationCommand/AppCommand.d.ts +18 -0
  2. package/dist/applicationCommand/AppCommand.js +25 -0
  3. package/dist/applicationCommand/AppCommand.js.map +1 -0
  4. package/dist/applicationCommand/decorator.d.ts +10 -0
  5. package/dist/{slashCommand → applicationCommand}/decorator.js +12 -8
  6. package/dist/applicationCommand/decorator.js.map +1 -0
  7. package/dist/applicationCommand/index.d.ts +2 -0
  8. package/dist/{slashCommand → applicationCommand}/index.js +4 -1
  9. package/dist/applicationCommand/index.js.map +1 -0
  10. package/dist/builtinModules/BuiltInModule.js +3 -0
  11. package/dist/builtinModules/BuiltInModule.js.map +1 -1
  12. package/dist/builtinModules/BuiltinApplicationCommandConverters.d.ts +8 -0
  13. package/dist/builtinModules/BuiltinApplicationCommandConverters.js +16 -0
  14. package/dist/builtinModules/BuiltinApplicationCommandConverters.js.map +1 -0
  15. package/dist/builtinModules/BuiltinCommandConverters.js +3 -0
  16. package/dist/builtinModules/BuiltinCommandConverters.js.map +1 -1
  17. package/dist/builtinModules/CommandHandler.d.ts +4 -1
  18. package/dist/builtinModules/CommandHandler.js +144 -17
  19. package/dist/builtinModules/CommandHandler.js.map +1 -1
  20. package/dist/builtinModules/index.d.ts +1 -1
  21. package/dist/builtinModules/index.js +4 -1
  22. package/dist/builtinModules/index.js.map +1 -1
  23. package/dist/command/ArgumentConverter.d.ts +3 -3
  24. package/dist/command/ArgumentConverter.js +6 -3
  25. package/dist/command/ArgumentConverter.js.map +1 -1
  26. package/dist/command/Command.d.ts +2 -2
  27. package/dist/command/Command.js +3 -0
  28. package/dist/command/Command.js.map +1 -1
  29. package/dist/command/cooldown/adapter.js +3 -0
  30. package/dist/command/cooldown/adapter.js.map +1 -1
  31. package/dist/command/cooldown/decorator.js +3 -0
  32. package/dist/command/cooldown/decorator.js.map +1 -1
  33. package/dist/command/cooldown/error.js +3 -0
  34. package/dist/command/cooldown/error.js.map +1 -1
  35. package/dist/command/cooldown/index.js +3 -0
  36. package/dist/command/cooldown/index.js.map +1 -1
  37. package/dist/command/cooldown/type.js +3 -0
  38. package/dist/command/cooldown/type.js.map +1 -1
  39. package/dist/command/decorator.d.ts +2 -1
  40. package/dist/command/decorator.js +9 -5
  41. package/dist/command/decorator.js.map +1 -1
  42. package/dist/command/index.js +3 -0
  43. package/dist/command/index.js.map +1 -1
  44. package/dist/command/utils.d.ts +2 -2
  45. package/dist/command/utils.js +9 -6
  46. package/dist/command/utils.js.map +1 -1
  47. package/dist/constants.d.ts +3 -2
  48. package/dist/constants.js +7 -3
  49. package/dist/constants.js.map +1 -1
  50. package/dist/error/ArgumentConverterNotFound.d.ts +6 -6
  51. package/dist/error/ArgumentConverterNotFound.js +6 -3
  52. package/dist/error/ArgumentConverterNotFound.js.map +1 -1
  53. package/dist/error/ArgumentNotProvided.js +3 -0
  54. package/dist/error/ArgumentNotProvided.js.map +1 -1
  55. package/dist/error/CommandCheckFailed.d.ts +6 -6
  56. package/dist/error/CommandCheckFailed.js +6 -3
  57. package/dist/error/CommandCheckFailed.js.map +1 -1
  58. package/dist/error/CommandNotFound.js +3 -0
  59. package/dist/error/CommandNotFound.js.map +1 -1
  60. package/dist/error/InvalidTargetError.js +3 -0
  61. package/dist/error/InvalidTargetError.js.map +1 -1
  62. package/dist/error/ModuleError.js +3 -0
  63. package/dist/error/ModuleError.js.map +1 -1
  64. package/dist/error/PermissionRequired.js +3 -0
  65. package/dist/error/PermissionRequired.js.map +1 -1
  66. package/dist/error/checks/DMOnlyCommand.js +3 -0
  67. package/dist/error/checks/DMOnlyCommand.js.map +1 -1
  68. package/dist/error/checks/GuildOnlyCommand.js +3 -0
  69. package/dist/error/checks/GuildOnlyCommand.js.map +1 -1
  70. package/dist/error/checks/OwnerOnlyCommand.js +3 -0
  71. package/dist/error/checks/OwnerOnlyCommand.js.map +1 -1
  72. package/dist/error/checks/SlashCommandGlobalCheckError.d.ts +5 -0
  73. package/dist/error/checks/SlashCommandGlobalCheckError.js +14 -0
  74. package/dist/error/checks/SlashCommandGlobalCheckError.js.map +1 -0
  75. package/dist/error/checks/index.js +3 -0
  76. package/dist/error/checks/index.js.map +1 -1
  77. package/dist/error/index.js +3 -0
  78. package/dist/error/index.js.map +1 -1
  79. package/dist/index.d.ts +2 -1
  80. package/dist/index.js +5 -1
  81. package/dist/index.js.map +1 -1
  82. package/dist/interface/index.js +3 -1
  83. package/dist/interface/index.js.map +1 -1
  84. package/dist/listener/Listener.js +3 -0
  85. package/dist/listener/Listener.js.map +1 -1
  86. package/dist/listener/decorator.js +3 -0
  87. package/dist/listener/decorator.js.map +1 -1
  88. package/dist/listener/index.js +3 -0
  89. package/dist/listener/index.js.map +1 -1
  90. package/dist/messageComponents/base.d.ts +10 -0
  91. package/dist/messageComponents/base.js +18 -0
  92. package/dist/messageComponents/base.js.map +1 -0
  93. package/dist/messageComponents/button.d.ts +5 -0
  94. package/dist/messageComponents/button.js +31 -0
  95. package/dist/messageComponents/button.js.map +1 -0
  96. package/dist/messageComponents/index.d.ts +2 -0
  97. package/dist/messageComponents/index.js +18 -0
  98. package/dist/messageComponents/index.js.map +1 -0
  99. package/dist/messageComponents/selectMenu.d.ts +5 -0
  100. package/dist/messageComponents/selectMenu.js +31 -0
  101. package/dist/messageComponents/selectMenu.js.map +1 -0
  102. package/dist/structures/CommandClient.d.ts +7 -3
  103. package/dist/structures/CommandClient.js +10 -8
  104. package/dist/structures/CommandClient.js.map +1 -1
  105. package/dist/structures/Module.d.ts +6 -4
  106. package/dist/structures/Module.js +9 -3
  107. package/dist/structures/Module.js.map +1 -1
  108. package/dist/structures/Registry.d.ts +6 -4
  109. package/dist/structures/Registry.js +21 -15
  110. package/dist/structures/Registry.js.map +1 -1
  111. package/dist/structures/index.js +3 -0
  112. package/dist/structures/index.js.map +1 -1
  113. package/dist/typings.d.ts +14 -2
  114. package/dist/typings.js +3 -0
  115. package/dist/typings.js.map +1 -1
  116. package/dist/utils.js +3 -0
  117. package/dist/utils.js.map +1 -1
  118. package/package.json +1 -3
  119. package/publish-version.js +7 -3
  120. package/src/applicationCommand/AppCommand.ts +32 -0
  121. package/src/{slashCommand → applicationCommand}/decorator.ts +14 -10
  122. package/src/applicationCommand/index.ts +6 -0
  123. package/src/builtinModules/BuiltInModule.ts +4 -0
  124. package/src/builtinModules/BuiltinApplicationCommandConverters.ts +16 -0
  125. package/src/builtinModules/BuiltinCommandConverters.ts +4 -0
  126. package/src/builtinModules/CommandHandler.ts +172 -20
  127. package/src/builtinModules/index.ts +5 -1
  128. package/src/command/ArgumentConverter.ts +7 -3
  129. package/src/command/Command.ts +6 -2
  130. package/src/command/cooldown/adapter.ts +4 -0
  131. package/src/command/cooldown/decorator.ts +4 -0
  132. package/src/command/cooldown/error.ts +4 -0
  133. package/src/command/cooldown/index.ts +4 -0
  134. package/src/command/cooldown/type.ts +4 -0
  135. package/src/command/decorator.ts +10 -5
  136. package/src/command/index.ts +4 -0
  137. package/src/command/utils.ts +13 -9
  138. package/src/constants.ts +8 -2
  139. package/src/error/ArgumentConverterNotFound.ts +8 -4
  140. package/src/error/ArgumentNotProvided.ts +4 -0
  141. package/src/error/CommandCheckFailed.ts +8 -4
  142. package/src/error/CommandNotFound.ts +4 -0
  143. package/src/error/InvalidTargetError.ts +4 -0
  144. package/src/error/ModuleError.ts +4 -0
  145. package/src/error/PermissionRequired.ts +4 -0
  146. package/src/error/checks/DMOnlyCommand.ts +4 -0
  147. package/src/error/checks/GuildOnlyCommand.ts +4 -0
  148. package/src/error/checks/OwnerOnlyCommand.ts +4 -0
  149. package/src/error/checks/SlashCommandGlobalCheckError.ts +11 -0
  150. package/src/error/checks/index.ts +4 -0
  151. package/src/error/index.ts +4 -0
  152. package/src/index.ts +6 -1
  153. package/src/interface/index.ts +4 -0
  154. package/src/listener/Listener.ts +4 -0
  155. package/src/listener/decorator.ts +4 -0
  156. package/src/listener/index.ts +4 -0
  157. package/src/messageComponents/base.ts +16 -0
  158. package/src/messageComponents/button.ts +30 -0
  159. package/src/messageComponents/index.ts +6 -0
  160. package/src/messageComponents/selectMenu.ts +30 -0
  161. package/src/structures/CommandClient.ts +20 -10
  162. package/src/structures/Module.ts +15 -6
  163. package/src/structures/Registry.ts +29 -19
  164. package/src/structures/index.ts +4 -0
  165. package/src/typings.ts +18 -2
  166. package/src/utils.ts +4 -0
  167. package/test/index.ts +6 -2
  168. package/test/modules/dev.ts +13 -5
  169. package/test/modules/test.ts +92 -15
  170. package/dist/builtinModules/BuiltinSlashCommandConverters.d.ts +0 -10
  171. package/dist/builtinModules/BuiltinSlashCommandConverters.js +0 -42
  172. package/dist/builtinModules/BuiltinSlashCommandConverters.js.map +0 -1
  173. package/dist/slashCommand/SlashCommand.d.ts +0 -19
  174. package/dist/slashCommand/SlashCommand.js +0 -22
  175. package/dist/slashCommand/SlashCommand.js.map +0 -1
  176. package/dist/slashCommand/decorator.d.ts +0 -10
  177. package/dist/slashCommand/decorator.js.map +0 -1
  178. package/dist/slashCommand/index.d.ts +0 -2
  179. package/dist/slashCommand/index.js.map +0 -1
  180. package/src/builtinModules/BuiltinSlashCommandConverters.ts +0 -23
  181. package/src/slashCommand/SlashCommand.ts +0 -29
  182. package/src/slashCommand/index.ts +0 -2
@@ -1,12 +1,27 @@
1
- import { command, CommandClient, coolDown, CoolDownError, CoolDownType, listener, Module, option, rest, slashCommand } from '../../src'
2
- import { CommandInteraction, Message } from 'discord.js'
3
- import { SlashCommandBuilder } from '@discordjs/builders'
1
+ /*
2
+ * Copyright (c) 2022 pikokr. Licensed under the MIT license
3
+ */
4
+
5
+ import { CommandClient, coolDown, CoolDownError, CoolDownType, listener, messageButton, messageSelectMenu, Module, option, applicationCommand } from '../../src'
6
+ import {
7
+ ButtonInteraction,
8
+ CommandInteraction,
9
+ ContextMenuInteraction,
10
+ Message,
11
+ MessageActionRow,
12
+ MessageButton,
13
+ MessageContextMenuInteraction,
14
+ MessageSelectMenu,
15
+ SelectMenuInteraction,
16
+ UserContextMenuInteraction,
17
+ } from 'discord.js'
4
18
 
5
19
  class Test extends Module {
6
20
  constructor(private client: CommandClient) {
7
21
  super()
8
22
  }
9
23
 
24
+ // region lifetime method
10
25
  load() {
11
26
  console.log('load')
12
27
  }
@@ -22,6 +37,7 @@ class Test extends Module {
22
37
  afterReload() {
23
38
  console.log('after reload')
24
39
  }
40
+ // endregion
25
41
 
26
42
  @listener('ready')
27
43
  ready() {
@@ -35,8 +51,8 @@ class Test extends Module {
35
51
  }
36
52
  console.error(err)
37
53
  }
38
- @listener('slashCommandError')
39
- slashCommandError(err: Error, msg: CommandInteraction) {
54
+ @listener('applicationCommandError')
55
+ slashCommandError(err: Error, msg: CommandInteraction | ContextMenuInteraction) {
40
56
  if (err instanceof CoolDownError) {
41
57
  return msg.reply({
42
58
  content: `쿨다운: <t:${(err.endsAt.getTime() / 1000).toFixed(0)}:R>`,
@@ -46,22 +62,83 @@ class Test extends Module {
46
62
  console.error(err)
47
63
  }
48
64
 
49
- @command()
65
+ @applicationCommand({
66
+ command: {
67
+ type: 'CHAT_INPUT',
68
+ name: 'test',
69
+ description: 'test',
70
+ options: [
71
+ {
72
+ type: 'STRING',
73
+ name: 'asdf',
74
+ description: 'test',
75
+ },
76
+ ],
77
+ },
78
+ })
50
79
  @coolDown(CoolDownType.USER, 10)
51
- test(msg: Message, @rest asdf: string = 'wa sans') {
52
- msg.reply(asdf)
80
+ coolDownSlash(i: CommandInteraction, @option('asdf') asdf: string = 'wa sans') {
81
+ i.reply({
82
+ content: asdf,
83
+ components: [
84
+ new MessageActionRow().addComponents(new MessageButton().setLabel('test').setCustomId('testButton').setStyle('PRIMARY')),
85
+ new MessageActionRow().addComponents(
86
+ new MessageSelectMenu()
87
+ .setCustomId('testSelectMenu')
88
+ .setPlaceholder('test')
89
+ .setMinValues(1)
90
+ .setOptions(
91
+ new Array(10).fill(1).map((_, i) => ({
92
+ label: `${i}`,
93
+ value: `${i}`,
94
+ })),
95
+ ),
96
+ ),
97
+ ],
98
+ })
53
99
  }
54
100
 
55
- @slashCommand({
56
- command: new SlashCommandBuilder()
57
- .setName('test')
58
- .setDescription('test command')
59
- .addStringOption((builder) => builder.setName('test').setDescription('test option').setRequired(false)),
101
+ @applicationCommand({
102
+ command: {
103
+ type: 'MESSAGE',
104
+ name: 'contextMenuTest',
105
+ defaultPermission: true,
106
+ },
60
107
  })
61
108
  @coolDown(CoolDownType.USER, 10)
62
- async testSlash(i: CommandInteraction, @option('test') test: string = 'wa sans') {
109
+ async contextMenuMessage(i: MessageContextMenuInteraction) {
63
110
  return i.reply({
64
- content: test,
111
+ content: `message id: ${i.targetMessage.id}`,
112
+ })
113
+ }
114
+
115
+ @applicationCommand({
116
+ command: {
117
+ type: 'USER',
118
+ name: 'contextMenuTest',
119
+ defaultPermission: true,
120
+ },
121
+ })
122
+ @coolDown(CoolDownType.USER, 10)
123
+ async contextMenuUser(i: UserContextMenuInteraction) {
124
+ return i.reply({
125
+ content: `user id: ${i.targetUser.id}`,
126
+ })
127
+ }
128
+
129
+ @messageButton('testButton')
130
+ async testButton(i: ButtonInteraction) {
131
+ await i.update({
132
+ content: 'test',
133
+ components: [],
134
+ })
135
+ }
136
+
137
+ @messageSelectMenu('testSelectMenu')
138
+ async testSelectMenu(i: SelectMenuInteraction) {
139
+ await i.update({
140
+ content: i.values.join(', '),
141
+ components: [],
65
142
  })
66
143
  }
67
144
  }
@@ -1,10 +0,0 @@
1
- import { BuiltInModule } from './BuiltInModule';
2
- import { Client, CommandInteraction, CommandInteractionOptionResolver } from 'discord.js';
3
- import { CommandClient } from '../structures';
4
- export declare class BuiltinSlashCommandConverters extends BuiltInModule {
5
- private cts;
6
- client: Client;
7
- constructor(cts: CommandClient);
8
- message(interaction: CommandInteraction): CommandInteraction<import("discord.js").CacheType>;
9
- optionResolver(interaction: CommandInteraction): CommandInteractionOptionResolver;
10
- }
@@ -1,42 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.BuiltinSlashCommandConverters = void 0;
13
- const BuiltInModule_1 = require("./BuiltInModule");
14
- const command_1 = require("../command");
15
- const discord_js_1 = require("discord.js");
16
- class BuiltinSlashCommandConverters extends BuiltInModule_1.BuiltInModule {
17
- constructor(cts) {
18
- super();
19
- this.cts = cts;
20
- this.client = cts.client;
21
- }
22
- message(interaction) {
23
- return interaction;
24
- }
25
- optionResolver(interaction) {
26
- return interaction.options;
27
- }
28
- }
29
- __decorate([
30
- command_1.slashArgumentConverter(discord_js_1.CommandInteraction),
31
- __metadata("design:type", Function),
32
- __metadata("design:paramtypes", [discord_js_1.CommandInteraction]),
33
- __metadata("design:returntype", void 0)
34
- ], BuiltinSlashCommandConverters.prototype, "message", null);
35
- __decorate([
36
- command_1.slashArgumentConverter(discord_js_1.CommandInteractionOptionResolver),
37
- __metadata("design:type", Function),
38
- __metadata("design:paramtypes", [discord_js_1.CommandInteraction]),
39
- __metadata("design:returntype", discord_js_1.CommandInteractionOptionResolver)
40
- ], BuiltinSlashCommandConverters.prototype, "optionResolver", null);
41
- exports.BuiltinSlashCommandConverters = BuiltinSlashCommandConverters;
42
- //# sourceMappingURL=BuiltinSlashCommandConverters.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BuiltinSlashCommandConverters.js","sourceRoot":"","sources":["../../src/builtinModules/BuiltinSlashCommandConverters.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAA+C;AAC/C,wCAAmD;AACnD,2CAAyF;AAGzF,MAAa,6BAA8B,SAAQ,6BAAa;IAG9D,YAAoB,GAAkB;QACpC,KAAK,EAAE,CAAA;QADW,QAAG,GAAH,GAAG,CAAe;QAEpC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAA;IAC1B,CAAC;IAGD,OAAO,CAAC,WAA+B;QACrC,OAAO,WAAW,CAAA;IACpB,CAAC;IAGD,cAAc,CAAC,WAA+B;QAC5C,OAAO,WAAW,CAAC,OAA2C,CAAA;IAChE,CAAC;CACF;AARC;IADC,gCAAsB,CAAC,+BAAkB,CAAC;;qCACtB,+BAAkB;;4DAEtC;AAGD;IADC,gCAAsB,CAAC,6CAAgC,CAAC;;qCAC7B,+BAAkB;oCAAG,6CAAgC;mEAEhF;AAhBH,sEAiBC"}
@@ -1,19 +0,0 @@
1
- import { SlashCommandBuilder } from '@discordjs/builders';
2
- import { Module } from '../structures';
3
- import { Snowflake } from 'discord.js';
4
- import { SlashCheckFunction } from '../command';
5
- export declare type SlashArgument = {
6
- type: any;
7
- name?: string;
8
- };
9
- export declare class SlashCommand {
10
- commandBuilder: SlashCommandBuilder | Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;
11
- private run;
12
- module: Module;
13
- params: SlashArgument[];
14
- guild: Snowflake | Snowflake[] | undefined;
15
- private key;
16
- get checks(): SlashCheckFunction[];
17
- execute(module: Module, args: any[]): any;
18
- constructor(commandBuilder: SlashCommandBuilder | Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>, run: Function, module: Module, params: SlashArgument[], guild: Snowflake | Snowflake[] | undefined, key: string | symbol);
19
- }
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SlashCommand = void 0;
4
- const constants_1 = require("../constants");
5
- class SlashCommand {
6
- constructor(commandBuilder, run, module, params, guild, key) {
7
- this.commandBuilder = commandBuilder;
8
- this.run = run;
9
- this.module = module;
10
- this.params = params;
11
- this.guild = guild;
12
- this.key = key;
13
- }
14
- get checks() {
15
- return Reflect.getMetadata(constants_1.KSlashCommandChecks, this.module, this.key) || [];
16
- }
17
- execute(module, args) {
18
- return this.run.apply(module, args);
19
- }
20
- }
21
- exports.SlashCommand = SlashCommand;
22
- //# sourceMappingURL=SlashCommand.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SlashCommand.js","sourceRoot":"","sources":["../../src/slashCommand/SlashCommand.ts"],"names":[],"mappings":";;;AAGA,4CAAkD;AAQlD,MAAa,YAAY;IASvB,YACS,cAAuG,EACtG,GAAa,EACd,MAAc,EACd,MAAuB,EACvB,KAA0C,EACzC,GAAoB;QALrB,mBAAc,GAAd,cAAc,CAAyF;QACtG,QAAG,GAAH,GAAG,CAAU;QACd,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAiB;QACvB,UAAK,GAAL,KAAK,CAAqC;QACzC,QAAG,GAAH,GAAG,CAAiB;IAC3B,CAAC;IAfJ,IAAI,MAAM;QACR,OAAO,OAAO,CAAC,WAAW,CAAC,+BAAmB,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;IAC9E,CAAC;IAED,OAAO,CAAC,MAAc,EAAE,IAAW;QACjC,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACrC,CAAC;CAUF;AAjBD,oCAiBC"}
@@ -1,10 +0,0 @@
1
- import { Snowflake } from 'discord.js';
2
- import { SlashCommandBuilder } from '@discordjs/builders';
3
- declare type SlashOptions = {
4
- guild: Snowflake | Snowflake[];
5
- };
6
- export declare const slashCommand: (opt: Partial<SlashOptions> & {
7
- command: SlashCommandBuilder | Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>;
8
- }) => (target: Object, propertyKey: string) => void;
9
- export declare const option: (key: string) => ParameterDecorator;
10
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../src/slashCommand/decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAkD;AAClD,oCAAsC;AACtC,4CAAmE;AAEnE,iDAA6C;AAOtC,MAAM,YAAY,GAAG,CAAC,GAAiI,EAAE,EAAE;IAChK,OAAO,CACL,MAAc,EACd,WAAmB,EAEnB,EAAE;QACF,mBAAW,CAAC,MAAM,CAAC,CAAA;QAEnB,IAAI,UAAU,GAAmB,OAAO,CAAC,WAAW,CAAC,0BAAc,EAAE,MAAM,CAAC,CAAA;QAE5E,MAAM,MAAM,GAAU,OAAO,CAAC,WAAW,CAAC,mBAAmB,EAAE,MAAM,EAAE,WAAW,CAAC,CAAA;QAEnF,MAAM,OAAO,GAA+B,OAAO,CAAC,WAAW,CAAC,gCAAoB,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,IAAI,uBAAU,EAAkB,CAAA;QAE9I,MAAM,OAAO,GAAG,IAAI,2BAAY,CAC9B,GAAG,CAAC,OAAO,EACX,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,EAChC,MAAgB,EAChB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YACpB,IAAI,EAAE,CAAC;YACP,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;SACrB,CAAC,CAAC,EACH,GAAG,CAAC,KAAK,EACT,WAAW,CACZ,CAAA;QAED,IAAI,UAAU,EAAE;YACd,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;SACzB;aAAM;YACL,UAAU,GAAG,CAAC,OAAO,CAAC,CAAA;YACtB,OAAO,CAAC,cAAc,CAAC,0BAAc,EAAE,UAAU,EAAE,MAAM,CAAC,CAAA;SAC3D;IACH,CAAC,CAAA;AACH,CAAC,CAAA;AAjCY,QAAA,YAAY,gBAiCxB;AAEM,MAAM,MAAM,GAAG,CAAC,GAAW,EAAsB,EAAE,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,EAAE;IACjG,mBAAW,CAAC,MAAM,CAAC,CAAA;IAEnB,IAAI,UAAU,GAA+B,OAAO,CAAC,WAAW,CAAC,gCAAoB,EAAE,MAAM,EAAE,WAAW,CAAC,CAAA;IAE3G,IAAI,CAAC,UAAU,EAAE;QACf,UAAU,GAAG,IAAI,uBAAU,EAAkB,CAAA;QAC7C,OAAO,CAAC,cAAc,CAAC,gCAAoB,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,CAAC,CAAA;KAC9E;IAED,UAAU,CAAC,GAAG,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;AACrC,CAAC,CAAA;AAXY,QAAA,MAAM,UAWlB"}
@@ -1,2 +0,0 @@
1
- export * from './decorator';
2
- export * from './SlashCommand';
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/slashCommand/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAA2B;AAC3B,iDAA8B"}
@@ -1,23 +0,0 @@
1
- import { BuiltInModule } from './BuiltInModule'
2
- import { slashArgumentConverter } from '../command'
3
- import { Client, CommandInteraction, CommandInteractionOptionResolver } from 'discord.js'
4
- import { CommandClient } from '../structures'
5
-
6
- export class BuiltinSlashCommandConverters extends BuiltInModule {
7
- client: Client
8
-
9
- constructor(private cts: CommandClient) {
10
- super()
11
- this.client = cts.client
12
- }
13
-
14
- @slashArgumentConverter(CommandInteraction)
15
- message(interaction: CommandInteraction) {
16
- return interaction
17
- }
18
-
19
- @slashArgumentConverter(CommandInteractionOptionResolver)
20
- optionResolver(interaction: CommandInteraction): CommandInteractionOptionResolver {
21
- return interaction.options as CommandInteractionOptionResolver
22
- }
23
- }
@@ -1,29 +0,0 @@
1
- import { SlashCommandBuilder } from '@discordjs/builders'
2
- import { Module } from '../structures'
3
- import { Snowflake } from 'discord.js'
4
- import { KSlashCommandChecks } from '../constants'
5
- import { SlashCheckFunction } from '../command'
6
-
7
- export type SlashArgument = {
8
- type: any
9
- name?: string
10
- }
11
-
12
- export class SlashCommand {
13
- get checks(): SlashCheckFunction[] {
14
- return Reflect.getMetadata(KSlashCommandChecks, this.module, this.key) || []
15
- }
16
-
17
- execute(module: Module, args: any[]) {
18
- return this.run.apply(module, args)
19
- }
20
-
21
- constructor(
22
- public commandBuilder: SlashCommandBuilder | Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>,
23
- private run: Function,
24
- public module: Module,
25
- public params: SlashArgument[],
26
- public guild: Snowflake | Snowflake[] | undefined,
27
- private key: string | symbol,
28
- ) {}
29
- }
@@ -1,2 +0,0 @@
1
- export * from './decorator'
2
- export * from './SlashCommand'