Refactor command packages
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
3474593dc9
commit
913e8e023a
@ -65,9 +65,9 @@ public class HidekoBot
|
||||
String botUserId = jda.getSelfUser().getId();
|
||||
Configuration.setBotApplicationId(botUserId);
|
||||
|
||||
// store if we have to force refresh commands despite no apparent changes.
|
||||
boolean forceUpdateCommands = false;
|
||||
|
||||
|
||||
// if there is more than 1 arg, then iterate through them because we have additional things to do.
|
||||
// we are doing this at the end because we might need the API to be already initialized for some things.
|
||||
if(args.length > 1) {
|
||||
|
@ -0,0 +1,33 @@
|
||||
package wtf.beatrice.hidekobot.commands.completer;
|
||||
|
||||
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
|
||||
import net.dv8tion.jda.api.interactions.commands.Command;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import wtf.beatrice.hidekobot.commands.slash.AvatarCommand;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AvatarCompleter
|
||||
{
|
||||
|
||||
public AvatarCompleter(@NotNull CommandAutoCompleteInteractionEvent event)
|
||||
{
|
||||
if(event.getFocusedOption().getName().equals("size"))
|
||||
{
|
||||
|
||||
List<Command.Choice> options = new ArrayList<>();
|
||||
|
||||
for(int res : AvatarCommand.acceptedSizes)
|
||||
{
|
||||
String resString = String.valueOf(res);
|
||||
String userInput = event.getFocusedOption().getValue();
|
||||
|
||||
if(resString.startsWith(userInput))
|
||||
options.add(new Command.Choice(resString, res));
|
||||
}
|
||||
|
||||
event.replyChoices(options).queue();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package wtf.beatrice.hidekobot.slashcommands;
|
||||
package wtf.beatrice.hidekobot.commands.slash;
|
||||
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.User;
|
@ -1,4 +1,4 @@
|
||||
package wtf.beatrice.hidekobot.slashcommands;
|
||||
package wtf.beatrice.hidekobot.commands.slash;
|
||||
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.MessageHistory;
|
@ -1,4 +1,4 @@
|
||||
package wtf.beatrice.hidekobot.slashcommands;
|
||||
package wtf.beatrice.hidekobot.commands.slash;
|
||||
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
@ -1,4 +1,4 @@
|
||||
package wtf.beatrice.hidekobot.slashcommands;
|
||||
package wtf.beatrice.hidekobot.commands.slash;
|
||||
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
@ -1,4 +1,4 @@
|
||||
package wtf.beatrice.hidekobot.slashcommands;
|
||||
package wtf.beatrice.hidekobot.commands.slash;
|
||||
|
||||
import net.dv8tion.jda.api.entities.channel.ChannelType;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
@ -1,4 +1,4 @@
|
||||
package wtf.beatrice.hidekobot.slashcommands;
|
||||
package wtf.beatrice.hidekobot.commands.slash;
|
||||
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
@ -2,11 +2,7 @@ package wtf.beatrice.hidekobot.listeners;
|
||||
|
||||
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import net.dv8tion.jda.api.interactions.commands.Command;
|
||||
import wtf.beatrice.hidekobot.slashcommands.AvatarCommand;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import wtf.beatrice.hidekobot.commands.completer.AvatarCompleter;
|
||||
|
||||
public class SlashCommandCompleter extends ListenerAdapter
|
||||
{
|
||||
@ -14,24 +10,8 @@ public class SlashCommandCompleter extends ListenerAdapter
|
||||
@Override
|
||||
public void onCommandAutoCompleteInteraction(CommandAutoCompleteInteractionEvent event)
|
||||
{
|
||||
if(event.getName().equals("avatar"))
|
||||
{
|
||||
if(event.getFocusedOption().getName().equals("size"))
|
||||
{
|
||||
|
||||
List<Command.Choice> options = new ArrayList<>();
|
||||
|
||||
for(int res : AvatarCommand.acceptedSizes)
|
||||
{
|
||||
String resString = String.valueOf(res);
|
||||
String userInput = event.getFocusedOption().getValue();
|
||||
|
||||
if(resString.startsWith(userInput))
|
||||
options.add(new Command.Choice(resString, res));
|
||||
}
|
||||
|
||||
event.replyChoices(options).queue();
|
||||
}
|
||||
switch (event.getName().toLowerCase()) {
|
||||
case "avatar" -> new AvatarCompleter(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package wtf.beatrice.hidekobot.listeners;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import wtf.beatrice.hidekobot.slashcommands.*;
|
||||
import wtf.beatrice.hidekobot.commands.slash.*;
|
||||
|
||||
public class SlashCommandListener extends ListenerAdapter
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user