File tree 1 file changed +10
-1
lines changed
application/src/main/java/org/togetherjava/tjbot/features 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 5
5
import net .dv8tion .jda .api .events .interaction .component .ButtonInteractionEvent ;
6
6
import net .dv8tion .jda .api .events .interaction .component .EntitySelectInteractionEvent ;
7
7
import net .dv8tion .jda .api .events .interaction .component .StringSelectInteractionEvent ;
8
+ import net .dv8tion .jda .api .interactions .InteractionContextType ;
8
9
import net .dv8tion .jda .api .interactions .commands .Command ;
9
10
import net .dv8tion .jda .api .interactions .commands .build .CommandData ;
10
11
import org .jetbrains .annotations .Contract ;
15
16
16
17
import java .util .List ;
17
18
import java .util .Objects ;
19
+ import java .util .Set ;
18
20
19
21
/**
20
22
* Adapter implementation of a {@link BotCommand}. The minimal setup only requires implementation of
@@ -51,7 +53,14 @@ public abstract class BotCommandAdapter implements BotCommand {
51
53
* @param visibility the visibility of the command
52
54
*/
53
55
protected BotCommandAdapter (CommandData data , CommandVisibility visibility ) {
54
- this .data = data .setGuildOnly (visibility == CommandVisibility .GUILD );
56
+ this .data = data ;
57
+
58
+ Set <InteractionContextType > contexts = switch (visibility ) {
59
+ case GUILD -> Set .of (InteractionContextType .GUILD );
60
+ case GLOBAL -> InteractionContextType .ALL ;
61
+ };
62
+
63
+ data .setContexts (contexts );
55
64
this .visibility = Objects .requireNonNull (visibility , "The visibility shouldn't be null" );
56
65
57
66
name = data .getName ();
You can’t perform that action at this time.
0 commit comments