forked from Fascinated/Bat
add ping command
This commit is contained in:
parent
a7f4a36c12
commit
154eac28d1
@ -0,0 +1,36 @@
|
||||
package cc.fascinated.bat.command.impl;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.model.BatGuild;
|
||||
import cc.fascinated.bat.model.BatUser;
|
||||
import cc.fascinated.bat.service.DiscordService;
|
||||
import lombok.NonNull;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.interactions.commands.SlashCommandInteraction;
|
||||
import net.dv8tion.jda.internal.interactions.CommandDataImpl;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author Fascinated (fascinated7)
|
||||
*/
|
||||
@Component
|
||||
public class PingCommand extends BatCommand {
|
||||
|
||||
public PingCommand() {
|
||||
super("ping");
|
||||
super.setDescription("Gets the ping of the bot");
|
||||
super.setCommandData(new CommandDataImpl(this.getName(), this.getDescription()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(@NonNull BatGuild guild, @NonNull BatUser user, @NonNull TextChannel channel, @NonNull Member member, @NonNull SlashCommandInteraction interaction) {
|
||||
long time = System.currentTimeMillis();
|
||||
interaction.reply("Pinging...").queue(response -> {
|
||||
response.editOriginal(("Gateway response time: `%sms`\nAPI response time `%sms`").formatted(
|
||||
DiscordService.JDA.getGatewayPing(),
|
||||
System.currentTimeMillis() - time
|
||||
)).queue();
|
||||
});
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package cc.fascinated.bat.service;
|
||||
|
||||
import cc.fascinated.bat.command.BatCommand;
|
||||
import cc.fascinated.bat.command.BatSubCommand;
|
||||
import cc.fascinated.bat.command.impl.PingCommand;
|
||||
import cc.fascinated.bat.common.EmbedUtils;
|
||||
import cc.fascinated.bat.features.scoresaber.command.numberone.NumberOneFeedCommand;
|
||||
import cc.fascinated.bat.features.scoresaber.command.scoresaber.ScoreSaberCommand;
|
||||
@ -50,12 +51,15 @@ public class CommandService extends ListenerAdapter {
|
||||
this.userService = userService;
|
||||
DiscordService.JDA.addEventListener(this);
|
||||
|
||||
// todo: auto register commands
|
||||
|
||||
// Guild commands
|
||||
registerCommand(context.getBean(UserFeedCommand.class));
|
||||
registerCommand(context.getBean(NumberOneFeedCommand.class));
|
||||
|
||||
// Global commands
|
||||
registerCommand(context.getBean(ScoreSaberCommand.class));
|
||||
registerCommand(context.getBean(PingCommand.class));
|
||||
|
||||
registerSlashCommands(); // Register all slash commands
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user