File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
application/src/main/java/org/togetherjava/tjbot/features Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 55import net .dv8tion .jda .api .events .interaction .component .ButtonInteractionEvent ;
66import net .dv8tion .jda .api .events .interaction .component .EntitySelectInteractionEvent ;
77import net .dv8tion .jda .api .events .interaction .component .StringSelectInteractionEvent ;
8+ import net .dv8tion .jda .api .interactions .InteractionContextType ;
89import net .dv8tion .jda .api .interactions .commands .Command ;
910import net .dv8tion .jda .api .interactions .commands .build .CommandData ;
1011import org .jetbrains .annotations .Contract ;
1516
1617import java .util .List ;
1718import java .util .Objects ;
19+ import java .util .Set ;
1820
1921/**
2022 * Adapter implementation of a {@link BotCommand}. The minimal setup only requires implementation of
@@ -51,7 +53,14 @@ public abstract class BotCommandAdapter implements BotCommand {
5153 * @param visibility the visibility of the command
5254 */
5355 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 );
5564 this .visibility = Objects .requireNonNull (visibility , "The visibility shouldn't be null" );
5665
5766 name = data .getName ();
You can’t perform that action at this time.
0 commit comments