Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/main/java/pw/chew/Chewbotcca/commands/about/PingCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package pw.chew.Chewbotcca.commands.about; | ||
|
||
import com.jagrosh.jdautilities.command.Command; | ||
import com.jagrosh.jdautilities.command.CommandEvent; | ||
import net.dv8tion.jda.api.EmbedBuilder; | ||
import net.dv8tion.jda.api.Permission; | ||
|
||
public class PingCommand extends Command { | ||
|
||
public PingCommand() { | ||
this.name = "ping"; | ||
this.help = "Ping the bot"; | ||
this.botPermissions = new Permission[]{Permission.MESSAGE_EMBED_LINKS}; | ||
this.guildOnly = false; | ||
} | ||
|
||
@Override | ||
protected void execute(CommandEvent commandEvent) { | ||
long time = commandEvent.getMessage().getTimeCreated().toInstant().toEpochMilli(); | ||
commandEvent.getChannel().sendMessage(new EmbedBuilder().setDescription("Checking ping..").build()).queue((msg) -> { | ||
EmbedBuilder eb = new EmbedBuilder().setDescription("Ping is " + (msg.getTimeCreated().toInstant().toEpochMilli() - time) + "ms"); | ||
msg.editMessage(eb.build()).queue(); | ||
}); | ||
commandEvent.getChannel().getLatestMessageId(); | ||
} | ||
} |