ClaptrapBot/src/main/java/net/Broken/Commands/Ping.java

45 lines
1.4 KiB
Java
Raw Normal View History

2018-01-12 12:50:12 +01:00
package net.Broken.Commands;
2016-12-08 20:05:23 +01:00
2017-03-20 18:44:53 +01:00
import net.Broken.Commande;
2017-10-16 17:03:17 +02:00
import net.Broken.MainBot;
import net.Broken.Tools.MessageTimeOut;
2017-03-20 21:01:49 +01:00
import net.dv8tion.jda.core.entities.ChannelType;
2017-10-16 17:03:17 +02:00
import net.dv8tion.jda.core.entities.Message;
2016-12-08 20:05:23 +01:00
import net.dv8tion.jda.core.events.message.MessageReceivedEvent;
import org.apache.logging.log4j.LogManager;
2016-12-08 20:05:23 +01:00
/**
2018-02-28 17:59:09 +01:00
* Command that return the Bot's ping
2016-12-08 20:05:23 +01:00
*/
2018-01-12 12:56:52 +01:00
public class Ping implements Commande {
2016-12-08 20:05:23 +01:00
@Override
public void action(String[] args, MessageReceivedEvent event) {
2018-01-12 12:50:12 +01:00
long ping = event.getJDA().getPing();
// long receivedTime = Timestamp.valueOf(LocalDateTime.ofInstant(event.getMessage().getCreationTime().toInstant(), ZoneId.systemDefault())).getTime();
2017-03-20 21:01:49 +01:00
if(event.isFromType(ChannelType.PRIVATE))
2018-01-12 12:50:12 +01:00
event.getPrivateChannel().sendMessage(":arrow_right: Pong! `" + ping+ "ms`").queue();
2017-10-16 17:03:17 +02:00
else {
2018-01-12 12:50:12 +01:00
Message rest = event.getTextChannel().sendMessage(event.getAuthor().getAsMention()+"\n:arrow_right: Pong! `" + ping + "ms`").complete();
2018-02-27 15:17:00 +01:00
new MessageTimeOut(MainBot.messageTimeOut, event.getMessage(), rest).start();
2017-10-16 17:03:17 +02:00
}
2017-09-04 18:36:23 +02:00
LogManager.getLogger().debug("pong");
2016-12-08 20:05:23 +01:00
}
2017-09-05 02:13:27 +02:00
@Override
public boolean isPrivateUsable() {
return true;
}
2018-02-23 19:17:23 +01:00
@Override
public boolean isAdminCmd() {
return false;
}
2018-02-27 15:17:00 +01:00
@Override
public boolean isNSFW() {
return false;
}
2016-12-08 20:05:23 +01:00
}