Last active
November 23, 2022 16:08
-
-
Save itsmefox/3eacbad53bcaa17acfb9d70a9302688e to your computer and use it in GitHub Desktop.
Creating a Discord Bot with Kotlin - PingCommand
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
class PingCommand : ListenerAdapter() { | |
private val logger: Logger = LoggerFactory.getLogger(javaClass) | |
//This gets called when a slash command gets used. | |
override fun onSlashCommandInteraction(event: SlashCommandInteractionEvent) { | |
//Check if this is our /ping command | |
if (event.name == "ping") { | |
logger.info("Command /ping got used") | |
//Reply to the user | |
val startTime = System.currentTimeMillis() | |
event.reply("Ping ...").setEphemeral(true).queue { | |
it.editOriginal("Pong: ${System.currentTimeMillis() - startTime}ms").queue() | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment