Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename SlashCommandInteractionOptionsProvider methods #1171

Merged
merged 2 commits into from
Oct 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ plugins {
`java-library`
`maven-publish`
signing
id("com.github.johnrengelman.shadow") version "2.0.4" apply false
id("net.researchgate.release") version "2.7.0" apply false
id("com.github.johnrengelman.shadow") version "7.1.2" apply false
id("net.researchgate.release") version "3.0.2" apply false
felldo marked this conversation as resolved.
Show resolved Hide resolved
}

repositories {
Expand Down
4 changes: 2 additions & 2 deletions javacord-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import java.time.Instant

plugins {
`java-library`
id("com.gorylenko.gradle-git-properties") version "2.4.0"
id("biz.aQute.bnd.builder") version "6.2.0"
id("com.gorylenko.gradle-git-properties") version "2.4.1"
id("biz.aQute.bnd.builder") version "6.3.1"
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
package org.javacord.api.interaction;

import java.util.List;

public interface SlashCommandInteraction extends ApplicationCommandInteraction, SlashCommandInteractionOptionsProvider {

/**
* Gets the arguments of this slash command if there are any.
*
* <p>This is a shorthand method to avoid checking for Subcommmands or SubcommandGroups
* to get the slash command arguments.
*
* @return The argument options.
*/
List<SlashCommandInteractionOption> getArguments();
Saladoc marked this conversation as resolved.
Show resolved Hide resolved

/**
* Gets the full command name of this slash command including the name of the Subcommand and SubcommandGroup.
*
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion javacord-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import aQute.bnd.version.MavenVersion.parseMavenString

plugins {
`java-library`
id("biz.aQute.bnd.builder") version "6.2.0"
id("biz.aQute.bnd.builder") version "6.3.1"
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public String getCommandName() {
return commandName;
}

// TODO: Move the implementation to the SlashCommandInteractionOptionsProvider once we upgraded to Java 9+
// because interfaces currently do not support private methods
@Override
public List<SlashCommandInteractionOption> getArguments() {
return getArgumentsRecursive(getOptions());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,21 @@ public Optional<CompletableFuture<Mentionable>> requestMentionableValue() {
public List<SlashCommandInteractionOption> getOptions() {
return Collections.unmodifiableList(options);
}

// TODO: Move the implementation to the SlashCommandInteractionOptionsProvider once we upgraded to Java 9+
// because interfaces currently do not support private methods
@Override
public List<SlashCommandInteractionOption> getArguments() {
return getArgumentsRecursive(getOptions());
}

private List<SlashCommandInteractionOption> getArgumentsRecursive(List<SlashCommandInteractionOption> options) {
if (options.isEmpty()) {
return Collections.emptyList();
} else if (options.get(0).isSubcommandOrGroup()) {
return getArgumentsRecursive(options.get(0).getOptions());
} else {
return options;
}
}
}