feat: updated JDACommand package
This commit is contained in:
parent
61e71e4dc4
commit
dfcf2fac3c
17 changed files with 80 additions and 41 deletions
|
@ -5,8 +5,11 @@ plugins {
|
|||
}
|
||||
|
||||
group = "de.limited_dev"
|
||||
version = "v1.5.3"
|
||||
|
||||
|
||||
version = "v1.5.4-build1"
|
||||
var splatoonPatchBased = "1.2.1"
|
||||
var jdaVersion = "5.0.0-alpha.20"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@ -14,7 +17,7 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation("net.dv8tion:JDA:5.0.0-alpha.20")
|
||||
implementation("net.dv8tion:JDA:$jdaVersion")
|
||||
implementation("org.slf4j:slf4j-api:2.0.3")
|
||||
implementation("org.slf4j:slf4j-simple:2.0.3")
|
||||
}
|
||||
|
@ -43,7 +46,7 @@ tasks {
|
|||
|
||||
withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
|
||||
dependencies {
|
||||
include(dependency("net.dv8tion:JDA:5.0.0-alpha.20"))
|
||||
include(dependency("net.dv8tion:JDA:$jdaVersion"))
|
||||
include(dependency("org.slf4j:slf4j-api:2.0.3"))
|
||||
include(dependency("org.slf4j:slf4j-simple:2.0.3"))
|
||||
}
|
||||
|
@ -59,7 +62,8 @@ tasks {
|
|||
filteringCharset = "UTF-8"
|
||||
val props = mapOf(
|
||||
"version" to version,
|
||||
"splatoonPatchBased" to splatoonPatchBased
|
||||
"splatoonPatchBased" to splatoonPatchBased,
|
||||
"jdaVersion" to jdaVersion
|
||||
)
|
||||
inputs.properties(props)
|
||||
from(templateSource)
|
||||
|
|
|
@ -7,18 +7,25 @@ import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEve
|
|||
public class JDACommand {
|
||||
|
||||
private final String name;
|
||||
private final String description;
|
||||
protected final Logger lgr = Main.getLgr();
|
||||
|
||||
public JDACommand(String name) {
|
||||
|
||||
public JDACommand(String name, String description) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
lgr.info("Created jda command " + name);
|
||||
}
|
||||
|
||||
public void onSlashCommand(SlashCommandInteractionEvent event){
|
||||
public void onSlashCommand(SlashCommandInteractionEvent event) {
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name.toLowerCase();
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ package de.limited_dev.lil_judd.commands.jdacommands.components;
|
|||
|
||||
import de.limited_dev.lil_judd.commands.jdacommands.management.RemoveFeatureCommand;
|
||||
import de.limited_dev.lil_judd.commands.jdacommands.management.SetupFeatureCommand;
|
||||
import de.limited_dev.lil_judd.commands.jdacommands.util.HelpCommand;
|
||||
import de.limited_dev.lil_judd.commands.jdacommands.util.InfoCommand;
|
||||
import de.limited_dev.lil_judd.commands.jdacommands.util.PingCommand;
|
||||
import de.limited_dev.lil_judd.commands.jdacommands.util.TranslateMapCommand;
|
||||
import de.limited_dev.lil_judd.commands.jdacommands.weapons.RandomWeaponCommand;
|
||||
import de.limited_dev.lil_judd.commands.jdacommands.weapons.WeaponInfoCommand;
|
||||
|
@ -20,13 +20,13 @@ public class JDACommandManager {
|
|||
//commands.add(new EndScrimCommand());
|
||||
//commands.add(new MessageScrimCommand());
|
||||
//commands.add(new ScrimInfoCommand());
|
||||
commands.add(new PingCommand());
|
||||
commands.add(new InfoCommand());
|
||||
commands.add(new SetupFeatureCommand());
|
||||
commands.add(new RemoveFeatureCommand());
|
||||
commands.add(new TranslateMapCommand());
|
||||
commands.add(new WeaponInfoCommand());
|
||||
commands.add(new RandomWeaponCommand());
|
||||
commands.add(new HelpCommand());
|
||||
}
|
||||
|
||||
public static List<JDACommand> getCommands() {
|
||||
|
|
|
@ -8,7 +8,7 @@ import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEve
|
|||
|
||||
public class RemoveFeatureCommand extends JDACommand {
|
||||
public RemoveFeatureCommand() {
|
||||
super("remove");
|
||||
super("remove", "Remove a feature");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,7 +8,7 @@ import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEve
|
|||
|
||||
public class SetupFeatureCommand extends JDACommand {
|
||||
public SetupFeatureCommand() {
|
||||
super("setup");
|
||||
super("setup", "Setup a feature");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,7 +9,7 @@ import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEve
|
|||
|
||||
public class EndScrimCommand extends JDACommand {
|
||||
public EndScrimCommand() {
|
||||
super("endscrim");
|
||||
super("endscrim", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,7 +9,7 @@ import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEve
|
|||
|
||||
public class MessageScrimCommand extends JDACommand {
|
||||
public MessageScrimCommand() {
|
||||
super("msgscrim");
|
||||
super("msgscrim", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,7 +7,7 @@ import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEve
|
|||
|
||||
public class ScrimInfoCommand extends JDACommand {
|
||||
public ScrimInfoCommand() {
|
||||
super("scriminfo");
|
||||
super("scriminfo", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
|
||||
public class SearchScrimCommand extends JDACommand {
|
||||
public SearchScrimCommand() {
|
||||
super("searchscrim");
|
||||
super("searchscrim", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package de.limited_dev.lil_judd.commands.jdacommands.util;
|
||||
|
||||
import de.limited_dev.lil_judd.commands.jdacommands.components.JDACommand;
|
||||
import de.limited_dev.lil_judd.commands.jdacommands.components.JDACommandManager;
|
||||
import de.limited_dev.lil_judd.util.EmbeddedMessageHelper;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class HelpCommand extends JDACommand {
|
||||
public HelpCommand() {
|
||||
super("help", "Shows all commands & their descriptions");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlashCommand(SlashCommandInteractionEvent event) {
|
||||
HashMap<String, String[]> values = new HashMap<>();
|
||||
CopyOnWriteArrayList<String> arguments = new CopyOnWriteArrayList<>();
|
||||
CopyOnWriteArrayList<String> disc = new CopyOnWriteArrayList<>();
|
||||
for (JDACommand c : JDACommandManager.getCommands()) {
|
||||
String commandArgs = c.getName();
|
||||
arguments.add(commandArgs);
|
||||
|
||||
disc.add(c.getDescription().isEmpty() ? "No description" : c.getDescription());
|
||||
}
|
||||
String[] argumentsArray = new String[arguments.size()];
|
||||
for (int i = 0; i < arguments.size(); i++) {
|
||||
argumentsArray[i] = arguments.get(i);
|
||||
}
|
||||
values.put("Command", argumentsArray);
|
||||
|
||||
String[] Descriptions = new String[disc.size()];
|
||||
for (int i = 0; i < disc.size(); i++) {
|
||||
Descriptions[i] = disc.get(i);
|
||||
}
|
||||
values.put("Description", Descriptions);
|
||||
|
||||
EmbeddedMessageHelper.sendWithTable(event, "Uses / commands", "Commands", Color.MAGENTA,
|
||||
null, "List of avalible commands", new String[]{"Command", "Description"}, values, true);
|
||||
}
|
||||
}
|
|
@ -13,14 +13,14 @@ import java.util.HashMap;
|
|||
|
||||
public class InfoCommand extends JDACommand {
|
||||
public InfoCommand() {
|
||||
super("info");
|
||||
super("info", "Shows Info about the bot");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlashCommand(SlashCommandInteractionEvent event) {
|
||||
HashMap<String, String[]> hm = new HashMap<>();
|
||||
hm.put("Information", new String[]{"Version", "Ping", "Uptime", "RAM", "# Commands"});
|
||||
hm.put("Value", new String[]{BuildConstants.botVersion, Main.getJda().getGatewayPing() + "ms", TimeUtil.getTimeFormatedShortend(Main.getUptime()),
|
||||
hm.put("Information", new String[]{"Version", "JDA version", "Ping", "Uptime", "RAM", "# Commands"});
|
||||
hm.put("Value", new String[]{BuildConstants.botVersion, BuildConstants.jdaVersion, Main.getJda().getGatewayPing() + "ms", TimeUtil.getTimeFormatedShortend(Main.getUptime()),
|
||||
(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024 + "MB / " + (Runtime.getRuntime().maxMemory() - (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())) / 1024 / 1024 + "MB; " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) * 100L / Runtime.getRuntime().maxMemory() + "%"
|
||||
, JDACommandManager.getCommands().size() + ""});
|
||||
EmbeddedMessageHelper.sendWithTable(event, Main.getJda().getSelfUser().getName() + " " + BuildConstants.botVersion, "Bot information", Color.YELLOW, Main.getJda().getSelfUser().getAvatarUrl(), "General information about the bot",
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
package de.limited_dev.lil_judd.commands.jdacommands.util;
|
||||
|
||||
|
||||
import de.limited_dev.lil_judd.Main;
|
||||
import de.limited_dev.lil_judd.commands.jdacommands.components.JDACommand;
|
||||
import de.limited_dev.lil_judd.util.EmbeddedMessageHelper;
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent;
|
||||
|
||||
public class PingCommand extends JDACommand {
|
||||
public PingCommand() {
|
||||
super("ping");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlashCommand(SlashCommandInteractionEvent event) {
|
||||
EmbeddedMessageHelper.sendSimpleOneLiner(event, "Connection speed", "My connection to base takes **" + Main.getJda().getGatewayPing() + "ms**", null);
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEve
|
|||
|
||||
public class TranslateMapCommand extends JDACommand {
|
||||
public TranslateMapCommand() {
|
||||
super("translatemap");
|
||||
super("mapinfo", "Show map information");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,7 +8,7 @@ import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEve
|
|||
|
||||
public class RandomWeaponCommand extends JDACommand {
|
||||
public RandomWeaponCommand() {
|
||||
super("randomweapon");
|
||||
super("randomweapon", "Get a random weapon");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.HashMap;
|
|||
|
||||
public class WeaponInfoCommand extends JDACommand {
|
||||
public WeaponInfoCommand() {
|
||||
super("weaponinfo");
|
||||
super("weaponinfo", "Get infos about a weapon");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,7 +10,7 @@ public class SlashCommandRegister {
|
|||
public static void registerCommands(){
|
||||
|
||||
Main.getJda().updateCommands().addCommands(
|
||||
Commands.slash("info", "Shows Info about me")
|
||||
Commands.slash("info", "Shows Info about the bot")
|
||||
.addOptions(new OptionData(OptionType.BOOLEAN, "mobileformatting", "Format the reply for mobile devices")),
|
||||
Commands.slash("setup", "Setup a feature")
|
||||
.addOptions(
|
||||
|
@ -33,13 +33,15 @@ public class SlashCommandRegister {
|
|||
.addOptions(new OptionData(OptionType.STRING, "message", "Message content", true)),
|
||||
Commands.slash("scriminfo", "Show info about the scrim system."),
|
||||
*/
|
||||
Commands.slash("translatemap", "Translate a Map from English to German or vice versa")
|
||||
Commands.slash("mapinfo", "Show map information")
|
||||
.addOptions(new OptionData(OptionType.STRING, "map", "Map Name", true)),
|
||||
Commands.slash("weaponinfo", "Get infos about a weapon")
|
||||
.addOptions(new OptionData(OptionType.STRING, "name", "Weapon name in English or German", true))
|
||||
.addOptions(new OptionData(OptionType.BOOLEAN, "mobileformatting", "Format the reply for mobile devices")),
|
||||
Commands.slash("randomweapon", "Get a random weapon")
|
||||
.addOptions(new OptionData(OptionType.BOOLEAN, "mobileformatting", "Format the reply for mobile devices"))//,
|
||||
.addOptions(new OptionData(OptionType.BOOLEAN, "mobileformatting", "Format the reply for mobile devices")),
|
||||
Commands.slash("help", "Shows all commands & their descriptions")
|
||||
.addOptions(new OptionData(OptionType.BOOLEAN, "mobileformatting", "Format the reply for mobile devices"))
|
||||
//Commands.context(Command.Type.USER, "Get user avatar"),
|
||||
//Commands.message("Get message ID")
|
||||
).queue();
|
||||
|
|
|
@ -3,4 +3,5 @@ package de.limited_dev.lil_judd.build;
|
|||
public class BuildConstants{
|
||||
public static String botVersion = "${version}";
|
||||
public static String splatoonPatchVersion = "${splatoonPatchBased}";
|
||||
public static String jdaVersion = "${jdaVersion}";
|
||||
}
|
Reference in a new issue