Skip to content

Commit

Permalink
Add Dispatchers.IO to get hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
WinG4merBR committed Jan 8, 2025
1 parent ff602b1 commit c4d7902
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.cakeyfox.foxy.command.vanilla.utils

import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import net.cakeyfox.common.FoxyEmotes
import net.cakeyfox.foxy.command.FoxyInteractionContext
import net.cakeyfox.foxy.command.structure.FoxyCommandExecutor
Expand All @@ -11,11 +13,14 @@ class PingExecutor : FoxyCommandExecutor() {
val gatewayPing = context.jda.gatewayPing
val currentShardId = context.jda.shardInfo.shardId + 1
val totalShards = context.jda.shardInfo.shardTotal
val hostname = withContext(Dispatchers.IO) {
InetAddress.getLocalHost().hostName
}

val response = pretty(FoxyEmotes.FoxyHowdy, "Ping\n") +
pretty(FoxyEmotes.FoxyWow, "Gateway Ping: ${gatewayPing}ms\n") +
pretty(FoxyEmotes.FoxyThink, "Shard ID: ${currentShardId}/${totalShards}\n") +
pretty(FoxyEmotes.FoxyCupcake, "Cluster: `${InetAddress.getLocalHost().hostName}`")
pretty(FoxyEmotes.FoxyCupcake, "Cluster: `$hostname`")

context.reply {
content = response
Expand Down

0 comments on commit c4d7902

Please # to comment.