1
1
package org .togetherjava .tjbot .commands ;
2
2
3
3
import net .dv8tion .jda .api .entities .Emoji ;
4
- import net .dv8tion .jda .api .events .interaction .command . SlashCommandInteractionEvent ;
5
- import net .dv8tion .jda .api .events .interaction .component . ButtonInteractionEvent ;
6
- import net .dv8tion .jda .api .events .interaction .component . SelectMenuInteractionEvent ;
4
+ import net .dv8tion .jda .api .events .interaction .ButtonClickEvent ;
5
+ import net .dv8tion .jda .api .events .interaction .SelectionMenuEvent ;
6
+ import net .dv8tion .jda .api .events .interaction .SlashCommandEvent ;
7
7
import net .dv8tion .jda .api .interactions .commands .build .CommandData ;
8
- import net .dv8tion .jda .api .interactions .commands .build .Commands ;
9
- import net .dv8tion .jda .api .interactions .commands .build .SlashCommandData ;
8
+ import net .dv8tion .jda .api .interactions .components .ButtonStyle ;
10
9
import net .dv8tion .jda .api .interactions .components .ComponentInteraction ;
11
- import net .dv8tion .jda .api .interactions .components .buttons .Button ;
12
- import net .dv8tion .jda .api .interactions .components .buttons .ButtonStyle ;
13
10
import org .jetbrains .annotations .NotNull ;
14
11
import org .togetherjava .tjbot .commands .componentids .ComponentId ;
15
12
import org .togetherjava .tjbot .commands .componentids .ComponentIdGenerator ;
31
28
* is then to be returned by {@link #getData()} where the system will then pick it up from.
32
29
* <p>
33
30
* After registration, the system will notify a command whenever one of its corresponding slash
34
- * commands ({@link #onSlashCommand(SlashCommandInteractionEvent )}), buttons
35
- * ({@link #onButtonClick(ButtonInteractionEvent , List)}) or menus
36
- * ({@link #onSelectionMenu(SelectMenuInteractionEvent , List)}) have been triggered.
31
+ * commands ({@link #onSlashCommand(SlashCommandEvent )}), buttons
32
+ * ({@link #onButtonClick(ButtonClickEvent , List)}) or menus
33
+ * ({@link #onSelectionMenu(SelectionMenuEvent , List)}) have been triggered.
37
34
* <p>
38
35
* <p>
39
36
* Some example commands are available in {@link org.togetherjava.tjbot.commands.basic}.
40
37
*/
41
- public interface SlashCommand extends Feature {
42
-
43
- /**
44
- * Gets the name of the command.
45
- * <p>
46
- * Requirements for this are documented in {@link Commands#slash(String, String)}.
47
- * <p>
48
- * <p>
49
- * After registration of the command, the name must not change anymore.
50
- *
51
- * @return the name of the command
52
- */
53
- @ NotNull
54
- String getName ();
38
+ public interface SlashCommand extends UserInteractor {
55
39
56
40
/**
57
41
* Gets the description of the command.
58
42
* <p>
59
- * Requirements for this are documented in {@link Commands#slash (String, String)}.
43
+ * Requirements for this are documented in {@link CommandData#CommandData (String, String)}.
60
44
* <p>
61
45
* <p>
62
46
* After registration of the command, the description must not change anymore.
@@ -92,7 +76,7 @@ public interface SlashCommand extends Feature {
92
76
* @return the command data of this command
93
77
*/
94
78
@ NotNull
95
- SlashCommandData getData ();
79
+ CommandData getData ();
96
80
97
81
/**
98
82
* Triggered by the core system when a slash command corresponding to this implementation (based
@@ -107,9 +91,9 @@ public interface SlashCommand extends Feature {
107
91
* <p>
108
92
* Buttons or menus have to be created with a component ID (see
109
93
* {@link ComponentInteraction#getComponentId()},
110
- * {@link Button#of(ButtonStyle, String, Emoji)}} ) in a very specific format, otherwise the core
111
- * system will fail to identify the command that corresponded to the button or menu click event
112
- * and is unable to route it back.
94
+ * {@link net.dv8tion.jda.api.interactions.components. Button#of(ButtonStyle, String, Emoji)}) in
95
+ * a very specific format, otherwise the core system will fail to identify the command that
96
+ * corresponded to the button or menu click event and is unable to route it back.
113
97
* <p>
114
98
* The component ID has to be a UUID-string (see {@link java.util.UUID}), which is associated to
115
99
* a specific database entry, containing meta information about the command being executed. Such
@@ -118,8 +102,8 @@ public interface SlashCommand extends Feature {
118
102
* given to {@link #acceptComponentIdGenerator(ComponentIdGenerator)} during system setup. The
119
103
* required {@link ComponentId} instance accepts optional extra arguments, which, if provided,
120
104
* can be picked up during the corresponding event (see
121
- * {@link #onButtonClick(ButtonInteractionEvent , List)},
122
- * {@link #onSelectionMenu(SelectMenuInteractionEvent , List)}).
105
+ * {@link #onButtonClick(ButtonClickEvent , List)},
106
+ * {@link #onSelectionMenu(SelectionMenuEvent , List)}).
123
107
* <p>
124
108
* Alternatively, if {@link SlashCommandAdapter} has been extended, it also offers a handy
125
109
* {@link SlashCommandAdapter#generateComponentId(String...)} method to ease the flow.
@@ -132,57 +116,5 @@ public interface SlashCommand extends Feature {
132
116
*
133
117
* @param event the event that triggered this
134
118
*/
135
- void onSlashCommand (@ NotNull SlashCommandInteractionEvent event );
136
-
137
- /**
138
- * Triggered by the core system when a button corresponding to this implementation (based on
139
- * {@link #getData()}) has been clicked.
140
- * <p>
141
- * This method may be called multi-threaded. In particular, there are no guarantees that it will
142
- * be executed on the same thread repeatedly or on the same thread that other event methods have
143
- * been called on.
144
- * <p>
145
- * Details are available in the given event and the event also enables implementations to
146
- * respond to it.
147
- * <p>
148
- * This method will be called in a multi-threaded context and the event may not be hold valid
149
- * forever.
150
- *
151
- * @param event the event that triggered this
152
- * @param args the arguments transported with the button, see
153
- * {@link #onSlashCommand(SlashCommandInteractionEvent)} for details on how these are
154
- * created
155
- */
156
- void onButtonClick (@ NotNull ButtonInteractionEvent event , @ NotNull List <String > args );
157
-
158
- /**
159
- * Triggered by the core system when a selection menu corresponding to this implementation
160
- * (based on {@link #getData()}) has been clicked.
161
- * <p>
162
- * This method may be called multi-threaded. In particular, there are no guarantees that it will
163
- * be executed on the same thread repeatedly or on the same thread that other event methods have
164
- * been called on.
165
- * <p>
166
- * Details are available in the given event and the event also enables implementations to
167
- * respond to it.
168
- * <p>
169
- * This method will be called in a multi-threaded context and the event may not be hold valid
170
- * forever.
171
- *
172
- * @param event the event that triggered this
173
- * @param args the arguments transported with the selection menu, see
174
- * {@link #onSlashCommand(SlashCommandInteractionEvent)} for details on how these are
175
- * created
176
- */
177
- void onSelectionMenu (@ NotNull SelectMenuInteractionEvent event , @ NotNull List <String > args );
178
-
179
- /**
180
- * Triggered by the core system during its setup phase. It will provide the command a component
181
- * id generator through this method, which can be used to generate component ids, as used for
182
- * button or selection menus. See {@link #onSlashCommand(SlashCommandInteractionEvent)} for
183
- * details on how to use this.
184
- *
185
- * @param generator the provided component id generator
186
- */
187
- void acceptComponentIdGenerator (@ NotNull ComponentIdGenerator generator );
119
+ void onSlashCommand (@ NotNull SlashCommandEvent event );
188
120
}
0 commit comments