WIP: add Message-Components handling/registry #21

Draft
tueem wants to merge 18 commits from feat/message-components into dev
4 changed files with 76 additions and 71 deletions
Showing only changes of commit 0b7b607a23 - Show all commits

View File

@ -13,27 +13,28 @@ public class AutocompleteIdentifierConverter implements IdentifierProvider.Conve
@Override @Override
public InteractionIdentifier convert(ChatInputAutoCompleteEvent context) { public InteractionIdentifier convert(ChatInputAutoCompleteEvent context) {
List<ApplicationCommandInteractionOption> options = Discord4JWrapper.SUB_FILTER.apply(context.getOptions()); InteractionIdentifier last = InteractionIdentifier.builder()
String commandName = context.getCommandName(); .type(InteractionType.AUTOCOMPLETE)
.name(context.getCommandName())
.build();
List<ApplicationCommandInteractionOption> options = Discord4JWrapper.SUB_FILTER.apply(context.getOptions());
if (!options.isEmpty()) { if (!options.isEmpty()) {
last = InteractionIdentifier.builder()
.type(InteractionType.AUTOCOMPLETE)
.name(options.getFirst().getName())
.parent(last)
.build();
List<ApplicationCommandInteractionOption> subOptions = Discord4JWrapper.SUB_FILTER.apply(options.getFirst().getOptions()); List<ApplicationCommandInteractionOption> subOptions = Discord4JWrapper.SUB_FILTER.apply(options.getFirst().getOptions());
if (!subOptions.isEmpty()) if (!subOptions.isEmpty())
return InteractionIdentifier.createHierarchy( last = InteractionIdentifier.builder()
InteractionType.AUTOCOMPLETE, .type(InteractionType.AUTOCOMPLETE)
commandName, .name(subOptions.getFirst().getName())
options.getFirst().getName(), .parent(last)
subOptions.getFirst().getName()); .build();
else }
return InteractionIdentifier.createHierarchy( return last;
InteractionType.AUTOCOMPLETE,
commandName,
options.getFirst().getName());
}else
return InteractionIdentifier.createHierarchy(
InteractionType.AUTOCOMPLETE,
commandName);
} }
} }

View File

@ -13,27 +13,28 @@ public class SlashCommandIdentifierConverter implements IdentifierProvider.Conve
@Override @Override
public InteractionIdentifier convert(ChatInputInteractionEvent context) { public InteractionIdentifier convert(ChatInputInteractionEvent context) {
InteractionIdentifier last = InteractionIdentifier.builder()
.type(InteractionType.COMMAND)
.name(context.getCommandName())
.build();
List<ApplicationCommandInteractionOption> options = Discord4JWrapper.SUB_FILTER.apply(context.getOptions()); List<ApplicationCommandInteractionOption> options = Discord4JWrapper.SUB_FILTER.apply(context.getOptions());
String commandName = context.getCommandName();
if (!options.isEmpty()) { if (!options.isEmpty()) {
List<ApplicationCommandInteractionOption> sub_options = Discord4JWrapper.SUB_FILTER.apply(options.getFirst().getOptions()); last = InteractionIdentifier.builder()
if (!sub_options.isEmpty()) .type(InteractionType.COMMAND)
return InteractionIdentifier.createHierarchy( .name(options.getFirst().getName())
InteractionType.COMMAND, .parent(last)
commandName, .build();
options.getFirst().getName(),
sub_options.getFirst().getName());
else
return InteractionIdentifier.createHierarchy(
InteractionType.COMMAND,
commandName,
options.getFirst().getName());
}else
return InteractionIdentifier.createHierarchy(
InteractionType.COMMAND,
commandName);
List<ApplicationCommandInteractionOption> subOptions = Discord4JWrapper.SUB_FILTER.apply(options.getFirst().getOptions());
if (!subOptions.isEmpty())
last = InteractionIdentifier.builder()
.type(InteractionType.COMMAND)
.name(subOptions.getFirst().getName())
.parent(last)
.build();
}
return last;
} }
} }

View File

@ -13,27 +13,28 @@ public class AutocompleteIdentifierConverter implements IdentifierProvider.Conve
@Override @Override
public InteractionIdentifier convert(AutocompleteInteraction context) { public InteractionIdentifier convert(AutocompleteInteraction context) {
List<SlashCommandInteractionOption> options = context.getOptions(); InteractionIdentifier last = InteractionIdentifier.builder()
String commandName = context.getCommandName(); .type(InteractionType.AUTOCOMPLETE)
.name(context.getCommandName())
.build();
List<SlashCommandInteractionOption> options = context.getOptions();
if (!options.isEmpty()) { if (!options.isEmpty()) {
last = InteractionIdentifier.builder()
.type(InteractionType.AUTOCOMPLETE)
.name(options.getFirst().getName())
.parent(last)
.build();
List<SlashCommandInteractionOption> subOptions = context.getOptions().getFirst().getOptions(); List<SlashCommandInteractionOption> subOptions = context.getOptions().getFirst().getOptions();
if (!subOptions.isEmpty()) if (!subOptions.isEmpty())
return InteractionIdentifier.createHierarchy( last = InteractionIdentifier.builder()
InteractionType.AUTOCOMPLETE, .type(InteractionType.AUTOCOMPLETE)
commandName, .name(subOptions.getFirst().getName())
options.getFirst().getName(), .parent(last)
subOptions.getFirst().getName()); .build();
else }
return InteractionIdentifier.createHierarchy( return last;
InteractionType.AUTOCOMPLETE,
commandName,
options.getFirst().getName());
}else
return InteractionIdentifier.createHierarchy(
InteractionType.AUTOCOMPLETE,
commandName);
} }
} }

View File

@ -13,26 +13,28 @@ public class SlashCommandIdentifierConverter implements IdentifierProvider.Conve
@Override @Override
public InteractionIdentifier convert(SlashCommandInteraction context) { public InteractionIdentifier convert(SlashCommandInteraction context) {
List<SlashCommandInteractionOption> options = context.getOptions(); InteractionIdentifier last = InteractionIdentifier.builder()
String commandName = context.getCommandName(); .type(InteractionType.COMMAND)
if (!options.isEmpty()) { .name(context.getCommandName())
List<SlashCommandInteractionOption> sub_options = context.getOptions().getFirst().getOptions(); .build();
if (!sub_options.isEmpty())
return InteractionIdentifier.createHierarchy(
InteractionType.COMMAND,
commandName,
options.getFirst().getName(),
sub_options.getFirst().getName());
else
return InteractionIdentifier.createHierarchy(
InteractionType.COMMAND,
commandName,
options.getFirst().getName());
}else
return InteractionIdentifier.createHierarchy(
InteractionType.COMMAND,
commandName);
List<SlashCommandInteractionOption> options = context.getOptions();
if (!options.isEmpty()) {
last = InteractionIdentifier.builder()
.type(InteractionType.COMMAND)
.name(options.getFirst().getName())
.parent(last)
.build();
List<SlashCommandInteractionOption> subOptions = context.getOptions().getFirst().getOptions();
if (!subOptions.isEmpty())
last = InteractionIdentifier.builder()
.type(InteractionType.COMMAND)
.name(subOptions.getFirst().getName())
.parent(last)
.build();
}
return last;
} }
} }