Files
Bat/src/main/java/cc/fascinated/bat/command/impl/PingCommand.java

34 lines
1.2 KiB
Java
Raw Normal View History

2024-06-25 12:32:06 +01:00
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 org.springframework.stereotype.Component;
/**
* @author Fascinated (fascinated7)
*/
@Component
public class PingCommand extends BatCommand {
public PingCommand() {
super("ping", "Gets the ping of the bot");
2024-06-25 12:32:06 +01:00
}
@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 -> {
2024-06-25 12:36:40 +01:00
response.editOriginal("Gateway response time: `%sms`\nAPI response time `%sms`".formatted(
2024-06-25 12:32:06 +01:00
DiscordService.JDA.getGatewayPing(),
System.currentTimeMillis() - time
)).queue();
});
}
}