8
8
import net .dv8tion .jda .api .JDA ;
9
9
import net .dv8tion .jda .api .events .session .ReadyEvent ;
10
10
import net .dv8tion .jda .api .hooks .ListenerAdapter ;
11
+ import net .dv8tion .jda .api .interactions .IntegrationType ;
12
+ import net .dv8tion .jda .api .interactions .InteractionContextType ;
11
13
import net .dv8tion .jda .api .interactions .commands .build .CommandData ;
12
14
import net .dv8tion .jda .api .interactions .commands .build .Commands ;
13
15
import net .dv8tion .jda .api .interactions .commands .build .SlashCommandData ;
@@ -40,8 +42,8 @@ private void registerCommands(JDA jda) {
40
42
}
41
43
try {
42
44
List <CommandData > commandDataList = commands .stream ()
43
- .filter (Command :: isAbleToRegisterOnGuild )
44
- .map (this ::convertToGuildCommandData )
45
+ .filter (command -> ! command . allowedIntegrations (). contains ( IntegrationType . UNKNOWN ) )
46
+ .map (this ::convertToCommandData )
45
47
.toList ();
46
48
jda .updateCommands ()
47
49
.addCommands (commandDataList )
@@ -58,12 +60,14 @@ private void registerCommands(JDA jda) {
58
60
* @param command Ninbot command to convert
59
61
* @return JDA CommandData
60
62
*/
61
- private CommandData convertToGuildCommandData (Command <?> command ) {
63
+ private CommandData convertToCommandData (Command <?> command ) {
62
64
return switch (command ) {
63
65
case SlashCommand slashCommand -> {
64
66
SlashCommandData slashCommandData = Commands .slash (slashCommand .getName (),
65
67
slashCommand .getDescription ())
66
- .setDefaultPermissions (slashCommand .getPermissions ());
68
+ .setDefaultPermissions (slashCommand .getPermissions ())
69
+ .setContexts (InteractionContextType .ALL )
70
+ .setIntegrationTypes (slashCommand .allowedIntegrations ());
67
71
try {
68
72
if (!slashCommand .getCommandOptions ().isEmpty ()) {
69
73
slashCommand .getCommandOptions ().forEach (slashCommandData ::addOptions );
@@ -78,9 +82,13 @@ private CommandData convertToGuildCommandData(Command<?> command) {
78
82
yield slashCommandData ;
79
83
}
80
84
case UserContextCommand userContextCommand -> Commands .user (userContextCommand .getName ())
81
- .setDefaultPermissions (userContextCommand .getPermissions ());
85
+ .setDefaultPermissions (userContextCommand .getPermissions ())
86
+ .setContexts (InteractionContextType .ALL )
87
+ .setIntegrationTypes (userContextCommand .allowedIntegrations ());
82
88
case MessageContextCommand messageContextCommand -> Commands .message (messageContextCommand .getName ())
83
- .setDefaultPermissions (messageContextCommand .getPermissions ());
89
+ .setDefaultPermissions (messageContextCommand .getPermissions ())
90
+ .setContexts (InteractionContextType .ALL )
91
+ .setIntegrationTypes (messageContextCommand .allowedIntegrations ());
84
92
default -> Commands .context (net .dv8tion .jda .api .interactions .commands .Command .Type .UNKNOWN , "null" );
85
93
};
86
94
}
0 commit comments