Update commands to use new subcommand methods

java-rewrite
Hammy 3 years ago
parent 30aa9f960c
commit 09c54c80d9

@ -1,28 +1,28 @@
package me.goudham.bot.command.info;
import io.micronaut.context.annotation.Executable;
import jakarta.inject.Inject;
import me.goudham.bot.command.ISlashCommand;
import me.goudham.command.annotation.SlashCommand;
import me.goudham.service.EmbedGenerator;
import me.goudham.service.EmbedService;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
import net.dv8tion.jda.api.interactions.InteractionHook;
@SlashCommand(name = "ping", description = "Display the latency of the bot", isVisible = true)
public class Ping implements ISlashCommand {
private final EmbedGenerator embedGenerator;
public class Ping {
private final EmbedService embedService;
@Inject
public Ping(EmbedGenerator embedGenerator) {
this.embedGenerator = embedGenerator;
public Ping(EmbedService embedService) {
this.embedService = embedService;
}
@Override
@Executable
public void handle(SlashCommandEvent event) {
event.deferReply(false).queue();
InteractionHook hook = event.getHook();
JDA jda = event.getJDA();
jda.getRestPing().queue(ping -> hook.sendMessageEmbeds(embedGenerator.getBaseEmbed().setDescription("**Rest ping: " + ping + "ms**\n**WS ping: " + jda.getGatewayPing() + "ms**").build()).queue());
jda.getRestPing().queue(ping -> hook.sendMessageEmbeds(embedService.getBaseEmbed().setDescription("**Rest ping: " + ping + "ms**\n**WS ping: " + jda.getGatewayPing() + "ms**").build()).queue());
}
}

@ -0,0 +1,22 @@
package me.goudham.bot.command.info.avatar;
import io.micronaut.context.annotation.Executable;
import me.goudham.command.annotation.SubCommand;
import me.goudham.command.annotation.SubCommandGroup;
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
@SubCommandGroup(parent = "avatar", name = "cool", description = "Just really cool stuff ya know")
public class AvatarCoolGroup {
@Executable
@SubCommand(name = "one", description = "just a really cool method that is called one")
public void oneCommand(SlashCommandEvent slashCommandEvent) {
}
@Executable
@SubCommand(name = "two", description = "just a really cool method that is called two")
public void twoCommand(SlashCommandEvent slashCommandEvent) {
}
}
Loading…
Cancel
Save