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;
|
2018-01-18 10:28:54 +01:00
|
|
|
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;
|
2017-02-04 19:31:09 +01:00
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
|
2017-10-16 17:03:17 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2017-03-20 21:01:49 +01:00
|
|
|
|
2016-12-08 20:05:23 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by seb65 on 19/10/2016.
|
|
|
|
*/
|
2018-01-12 12:56:52 +01:00
|
|
|
public class Ping implements Commande {
|
2016-12-08 20:05:23 +01:00
|
|
|
|
|
|
|
|
2018-01-12 12:50:12 +01:00
|
|
|
private String HELP = "`//ping` \n :arrow_right:\t*Renvoi le ping du bot*";
|
2016-12-08 20:05:23 +01:00
|
|
|
@Override
|
|
|
|
public boolean called(String[] args, MessageReceivedEvent event) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@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();
|
2017-10-16 17:03:17 +02:00
|
|
|
List<Message> messages = new ArrayList<Message>(){{
|
|
|
|
add(rest);
|
|
|
|
add(event.getMessage());
|
|
|
|
}};
|
|
|
|
new MessageTimeOut(messages, MainBot.messageTimeOut).start();
|
|
|
|
}
|
2017-09-04 18:36:23 +02:00
|
|
|
LogManager.getLogger().debug("pong");
|
2016-12-08 20:05:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String help(String[] args) {
|
|
|
|
|
|
|
|
return HELP;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void executed(boolean success, MessageReceivedEvent event)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
2017-09-05 02:13:27 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isPrivateUsable() {
|
|
|
|
return true;
|
|
|
|
}
|
2016-12-08 20:05:23 +01:00
|
|
|
}
|