Skip to content

Commit

Permalink
Merge pull request #6 from Goksi/fix/arithmetic-exception
Browse files Browse the repository at this point in the history
Fixing arithmetic exception when server memory is set to unlimited
  • Loading branch information
Goksi authored Nov 17, 2022
2 parents e120b60 + 99df9f5 commit c4ba00e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/kotlin/tech/goksi/pterobot/commands/Servers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class Servers(jda: JDA) : SimpleCommand() {
}
event.deferReply(ConfigManager.config.getBoolean("BotInfo.Ephemeral")).queue()
val pteroMember = PteroMember(event.user)

event.message.delete().queue()
if (!pteroMember.isLinked()) {
event.hook.sendMessageEmbeds(
EmbedManager
Expand Down Expand Up @@ -254,7 +254,7 @@ class Servers(jda: JDA) : SimpleCommand() {
emoji = Emoji.fromUnicode(getButtonSetting("CloseEmoji"))
) {
it.deferEdit().queue()
val original = it.hook.retrieveOriginal().await()
it.hook.retrieveOriginal().queue { msg -> msg.delete().queue() }
}
event.hook.sendMessageEmbeds(response).addActionRow(
changeStateButton,
Expand Down
8 changes: 7 additions & 1 deletion src/main/kotlin/tech/goksi/pterobot/entities/ServerInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package tech.goksi.pterobot.entities

import com.mattmalec.pterodactyl4j.client.entities.ClientServer
import tech.goksi.pterobot.NodeStatus
import tech.goksi.pterobot.util.Common

data class ServerInfo(private val server: ClientServer) {
val identifier: String = server.identifier
val name: String = server.name
Expand All @@ -13,7 +15,11 @@ data class ServerInfo(private val server: ClientServer) {
val diskUsed = (utilization.disk.toFloat()) / 1024 / 1024 / 1024 //gb
val ramUsed = utilization.memory / 1024 / 1024 //mb
val diskMax = (server.limits.diskLong.toFloat()) / 1024
val ramMax = server.limits.memoryLong
val ramMax: Long
get() {
return if (server.limits.memoryLong != 0L) server.limits.memoryLong
else Common.getDefaultApplication().retrieveNodesByName(server.node, false).execute()[0].memoryLong
}
val emoji = when (status) {
"RUNNING" -> NodeStatus.ONLINE.emoji
"STARTING" -> NodeStatus.ONLINE.emoji
Expand Down

0 comments on commit c4ba00e

Please sign in to comment.