-
-
Notifications
You must be signed in to change notification settings - Fork 727
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
Add SlashCommandEvent.getCommandString #1693
Add SlashCommandEvent.getCommandString #1693
Conversation
(Updated Files from last PR, branch corrupted)
src/main/java/net/dv8tion/jda/api/interactions/commands/CommandInteraction.java
Outdated
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/api/interactions/commands/CommandInteraction.java
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/api/interactions/commands/CommandInteraction.java
Outdated
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/api/interactions/commands/CommandInteraction.java
Outdated
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/api/interactions/commands/CommandInteraction.java
Outdated
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/api/interactions/commands/CommandInteraction.java
Outdated
Show resolved
Hide resolved
src/main/java/net/dv8tion/jda/api/interactions/commands/CommandInteraction.java
Outdated
Show resolved
Hide resolved
I really wish this had some tests around it |
https://hastebin.com/enozukomah.typescript unless I'm misunderstanding what you're wanting; could you then clarify? |
Please post your snippets here on Github because hastebin will eventually time out and we will lose that code. This line seems like it's wrong |
src/main/java/net/dv8tion/jda/api/interactions/commands/CommandInteraction.java
Outdated
Show resolved
Hide resolved
package me.vixen.testing;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.events.ReadyEvent;
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import net.dv8tion.jda.api.interactions.commands.*;
import org.jetbrains.annotations.NotNull;
import javax.security.auth.login.LoginException;
public class Entry extends ListenerAdapter {
public static void main(String[] args) throws LoginException, InterruptedException {
JDA jda = JDABuilder.createLight(token)
.addEventListeners(new Entry())
.build()
.awaitReady();
jda.getGuildById("761703507546996786").updateCommands().addCommands(
new CommandData("command1", "command1").addSubcommandGroups( //name
new SubcommandGroupData("subgroup1", "subgroup1").addSubcommands( //subcommand group
new SubcommandData("subcommand1", "subcommand1").addOptions( //subcommand
new OptionData(OptionType.STRING, "option1", "Option 1", true), //option1
new OptionData(OptionType.STRING, "option2", "Option 2", true) //option2
)
)
),
new CommandData("command2", "Command 2").addSubcommands( //name
new SubcommandData("subcommand2", "sub command 2").addOptions( //subcommand
new OptionData(OptionType.STRING, "option1", "Option 1", true), //option1
new OptionData(OptionType.STRING, "option2", "Option 2", true) //option2
)
),
new CommandData("command3", "Command 3").addOptions( //name
new OptionData(OptionType.STRING, "option1", "Option 1", true), //option1
new OptionData(OptionType.STRING, "option2", "Option 2", true) //option2
),
new CommandData("command4", "Command 4").addOptions( //name
new OptionData(OptionType.STRING, "option1", "Option 1", true), //option1
new OptionData(OptionType.INTEGER, "option2", "Option 2", true), //option2
new OptionData(OptionType.BOOLEAN, "option3", "Option 3", true), //option2
new OptionData(OptionType.CHANNEL, "option4", "Option 4", true), //option2
new OptionData(OptionType.MENTIONABLE, "option5", "Option 5", true), //option2
new OptionData(OptionType.ROLE, "option6", "Option 6", true), //option2
new OptionData(OptionType.USER, "option7", "Option 7", true) //option2
),
new CommandData("command5", "command 5") //name
).queue();
}
@Override
public void onReady(@NotNull ReadyEvent event) {
System.out.println("JDA Ready");
}
@Override
public void onSlashCommand(@NotNull SlashCommandEvent event) {
System.out.println(event.getCommandString());
event.reply("reply").queue();
}
}
//TEST INPUTS
/command1 subgroup1 subcommand1 option1: opt1 option2: opt2
/command2 subcommand2 option1: opt1 option2: opt2
/command3 option1: opt1 option2: opt2
/command4 option1: opt1 option2: 100 option3: true option4: #chat option5: @Vixen option6: @Vixen V2 option7: @Chop
/command5
// OUTPUTS
/command1 subgroup1 subcommand1 option1: opt1 option2: opt2
/command2 subcommand2 option1: opt1 option2: opt2
/command3 option1: opt1 option2: opt2
/command4 option1: opt1 option2: 100 option3: true option4: #chat option5: @867602586257195028 option6: @Vixen V2 option7: @Chop
/command5 |
The 'input' section is how it appears on the client.
Did some more testing, realized that the See updated files below |
src/main/java/net/dv8tion/jda/api/interactions/commands/CommandInteraction.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Florian Spieß <business@minnced.club>
5f0e86a
to
f35deec
Compare
Co-authored-by: Florian Spieß <business@minnced.club>
(Updated Files from last PR, branch corrupted)
Pull Request Etiquette
Changes
Closes Issue: NaN
Description
Adds SlashCommandEvent#getCommandString() which will provide the text the user typed in to activate the command:
Ex:
/say phrase: Hello World! mention: @ Johnny