diff --git a/src/main/kotlin/tech/goksi/pterobot/EmbedType.kt b/src/main/kotlin/tech/goksi/pterobot/EmbedType.kt index f451c01..8beb597 100644 --- a/src/main/kotlin/tech/goksi/pterobot/EmbedType.kt +++ b/src/main/kotlin/tech/goksi/pterobot/EmbedType.kt @@ -1,12 +1,12 @@ package tech.goksi.pterobot enum class EmbedType(private val fileName: String) { - GENERIC_ERROR("generic_error.json"), - GENERIC_SUCCESS("generic_success.json"), - NODE_INFO("node_info.json"), - SERVERS_COMMAND("servers_command.json"), - SERVER_INFO("server_info.json"), - NODE_STATUS("node_status.json"); + GENERIC_ERROR("generic_error.yml"), + GENERIC_SUCCESS("generic_success.yml"), + NODE_INFO("node_info.yml"), + SERVERS_COMMAND("server_list.yml"), + SERVER_INFO("server_info.yml"), + NODE_STATUS("node_status.yml"); val path get() = "embeds/$fileName" diff --git a/src/main/kotlin/tech/goksi/pterobot/commands/AccountCommand.kt b/src/main/kotlin/tech/goksi/pterobot/commands/AccountCommand.kt index 4ab1a12..94abc4c 100644 --- a/src/main/kotlin/tech/goksi/pterobot/commands/AccountCommand.kt +++ b/src/main/kotlin/tech/goksi/pterobot/commands/AccountCommand.kt @@ -68,19 +68,19 @@ private class Link : SimpleSubcommand( ConfigManager.config.getString("$ACCOUNT_PREFIX.Link.LinkSuccess") .replace("%pteroName", account.userName) ) - .toEmbed(event.jda) + .toEmbed() } catch (exception: SQLException) { logger.error("Failed to link ${event.user.idLong}", exception) EmbedManager.getGenericFailure(ConfigManager.config.getString("Messages.Embeds.UnexpectedError")) - .toEmbed(event.jda) + .toEmbed() } catch (httpException: HttpException) { EmbedManager.getGenericFailure(ConfigManager.config.getString("$ACCOUNT_PREFIX.Link.LinkWrongKey")) - .toEmbed(event.jda) // its probably wrong key if we got here, add check maybe + .toEmbed() // its probably wrong key if we got here, add check maybe } } else { response = EmbedManager.getGenericFailure(ConfigManager.config.getString("$ACCOUNT_PREFIX.Link.LinkExist")) - .toEmbed(event.jda) + .toEmbed() } event.reply_(embeds = listOf(response)).queue() } @@ -105,7 +105,7 @@ private class Unlink : SimpleSubcommand( embeds = listOf( EmbedManager .getGenericSuccess(ConfigManager.config.getString("$ACCOUNT_PREFIX.Unlink.SuccessUnlink")) - .toEmbed(event.jda) + .toEmbed() ) ).queue() } else { @@ -113,7 +113,7 @@ private class Unlink : SimpleSubcommand( embeds = listOf( EmbedManager .getGenericFailure(ConfigManager.config.getString("$ACCOUNT_PREFIX.Unlink.NotLinked")) - .toEmbed(event.jda) + .toEmbed() ) ).queue() } @@ -170,7 +170,7 @@ private class Register : SimpleSubcommand( !event.member!!.hasPermission(Permission.ADMINISTRATOR) ) { event.replyEmbeds( - EmbedManager.getGenericFailure("$ACCOUNT_PREFIX.Register.DisabledMessage").toEmbed(event.jda) + EmbedManager.getGenericFailure("$ACCOUNT_PREFIX.Register.DisabledMessage").toEmbed() ).queue() return } @@ -182,7 +182,7 @@ private class Register : SimpleSubcommand( EmbedManager.getGenericFailure( ConfigManager.config.getString("$ACCOUNT_PREFIX.Register.LimitReached") .replace("%accounts", pteroMember.registeredAccounts.joinToString(",")) - ).toEmbed(event.jda) + ).toEmbed() ).setEphemeral(true).queue() } } @@ -197,7 +197,7 @@ private class Register : SimpleSubcommand( ConfigManager.config.getString( "$ACCOUNT_PREFIX.Register.InvalidEmail" ) - ).toEmbed(event.jda) + ).toEmbed() ) .queue() return @@ -217,7 +217,7 @@ private class Register : SimpleSubcommand( EmbedManager.getGenericSuccess( ConfigManager.config.getString("$ACCOUNT_PREFIX.Register.Success")!! .replace("%pteroName", it.userName) - ).toEmbed(event.jda) + ).toEmbed() ).queue() PteroMember(event.user).registerAccount(it.userName) }, { @@ -231,11 +231,11 @@ private class Register : SimpleSubcommand( EmbedManager.getGenericFailure( ConfigManager.config.getString("$ACCOUNT_PREFIX.Register.FieldTaken") .replace("%takenField", takenField) - ).toEmbed(event.jda) + ).toEmbed() ).queue() } else event.hook.sendMessageEmbeds( EmbedManager.getGenericFailure(ConfigManager.config.getString("Messages.Embeds.UnexpectedError")) - .toEmbed(event.jda) + .toEmbed() ).queue() }) } diff --git a/src/main/kotlin/tech/goksi/pterobot/commands/NodeCommand.kt b/src/main/kotlin/tech/goksi/pterobot/commands/NodeCommand.kt index 3489fb3..b74a6b0 100644 --- a/src/main/kotlin/tech/goksi/pterobot/commands/NodeCommand.kt +++ b/src/main/kotlin/tech/goksi/pterobot/commands/NodeCommand.kt @@ -11,7 +11,6 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import net.dv8tion.jda.api.EmbedBuilder -import net.dv8tion.jda.api.JDA import net.dv8tion.jda.api.Permission import net.dv8tion.jda.api.entities.MessageEmbed import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent @@ -79,7 +78,6 @@ private class Info : SimpleSubcommand( withContext(NodeCommand.coroutineScope.coroutineContext) { getNodeInfoEmbed( nodeId, - event.jda, pteroMember.client!! ) } @@ -89,21 +87,21 @@ private class Info : SimpleSubcommand( success = false logger.debug("Thrown exception: ", exception) EmbedManager.getGenericFailure(ConfigManager.config.getString("$NODE_PREFIX.Info.NodeNotFound")) - .toEmbed(event.jda) + .toEmbed() } // shame that kotlin doesn't have multi catch else -> throw exception } } } else { response = EmbedManager.getGenericFailure(ConfigManager.config.getString("$NODE_PREFIX.Info.NotAdmin")) - .toEmbed(event.jda) + .toEmbed() } event.hook.sendMessageEmbeds(response).queue { if (success && update) { val job = NodeCommand.coroutineScope.launch { while (true) { delay(300_000) - it.editMessageEmbeds(getNodeInfoEmbed(nodeId, event.jda, pteroMember.client!!)).queue() + it.editMessageEmbeds(getNodeInfoEmbed(nodeId, pteroMember.client!!)).queue() } } /*TODO: fixed 5 minutes delay, make configurable*/ NodeCommand.taskMap[it.idLong] = job @@ -111,7 +109,7 @@ private class Info : SimpleSubcommand( } } - private suspend fun getNodeInfoEmbed(id: Int, jda: JDA, pteroClient: PteroClient): MessageEmbed { + private suspend fun getNodeInfoEmbed(id: Int, pteroClient: PteroClient): MessageEmbed { val pteroApplication = Common.getDefaultApplication() val node = pteroApplication.retrieveNodeById(id.toLong()).await() var memoryUsed: Long = 0 @@ -144,7 +142,7 @@ private class Info : SimpleSubcommand( diskUsed = diskSpaceUsed, cpuUsed = cpuUsed ) - ).toEmbed(jda) + ).toEmbed() } } @@ -167,13 +165,13 @@ private class Status : SimpleSubcommand( val update = event.getOption("update")?.asBoolean ?: false event.deferReply(ConfigManager.config.getBoolean("BotInfo.Ephemeral")).queue() - event.hook.sendMessageEmbeds(withContext(NodeCommand.coroutineScope.coroutineContext) { getInfoEmbed(event.jda) }) + event.hook.sendMessageEmbeds(withContext(NodeCommand.coroutineScope.coroutineContext) { getInfoEmbed() }) .queue { if (update) { val job = NodeCommand.coroutineScope.launch { while (true) { delay(300_000) - it.editMessageEmbeds(getInfoEmbed(event.jda)) + it.editMessageEmbeds(getInfoEmbed()) .queue() } } @@ -183,13 +181,13 @@ private class Status : SimpleSubcommand( } else { event.replyEmbeds( EmbedManager.getGenericFailure(ConfigManager.config.getString("$NODE_PREFIX.Status.NotAdmin")) - .toEmbed(event.jda) + .toEmbed() ) } } - private fun getInfoEmbed(jda: JDA): MessageEmbed { - val embedBuilder = EmbedBuilder(EmbedManager.getNodeStatus().toEmbed(jda)) + private fun getInfoEmbed(): MessageEmbed { + val embedBuilder = EmbedBuilder(EmbedManager.getNodeStatus().toEmbed()) val fieldTemplate = embedBuilder.fields[0].also { embedBuilder.clearFields() } val pteroApplication = Common.getDefaultApplication() pteroApplication.retrieveNodes().forEach { node -> diff --git a/src/main/kotlin/tech/goksi/pterobot/commands/ServerCommand.kt b/src/main/kotlin/tech/goksi/pterobot/commands/ServerCommand.kt index 678a0b7..6c5ecdd 100644 --- a/src/main/kotlin/tech/goksi/pterobot/commands/ServerCommand.kt +++ b/src/main/kotlin/tech/goksi/pterobot/commands/ServerCommand.kt @@ -58,12 +58,12 @@ private class List(jda: JDA) : SimpleSubcommand( server.sendCommand(it.getValue("command")!!.asString).executeAsync({ _ -> it.replyEmbeds( EmbedManager.getGenericSuccess(ConfigManager.config.getString("$SERVER_PATH.List.SuccessCommand")) - .toEmbed(it.jda) + .toEmbed() ).setEphemeral(true).queue() }) { throwable -> it.replyEmbeds( EmbedManager.getGenericFailure(ConfigManager.config.getString("Embeds.UnexpectedError")) - .toEmbed(it.jda) + .toEmbed() ).setEphemeral(true).queue() logger.error("Error while sending command to ${server.name}", throwable) } @@ -81,7 +81,7 @@ private class List(jda: JDA) : SimpleSubcommand( event.hook.sendMessageEmbeds( EmbedManager .getGenericFailure(ConfigManager.config.getString("$SERVER_PATH.List.NotFound")) - .toEmbed(event.jda) + .toEmbed() ).queue() return } @@ -91,13 +91,13 @@ private class List(jda: JDA) : SimpleSubcommand( } this.placeholder = ConfigManager.config.getString("$SERVER_PATH.List.MenuPlaceholder") } - val response = EmbedManager.getServersCommand(AccountInfo(pteroMember.getAccount())).toEmbed(event.jda) + val response = EmbedManager.getServersCommand(AccountInfo(pteroMember.getAccount())).toEmbed() event.hook.sendMessageEmbeds(response).addActionRow(selectMenu).queue() } else { event.hook.sendMessageEmbeds( EmbedManager - .getGenericFailure(ConfigManager.config.getString("$SERVER_PATH.List.NotLinked")).toEmbed(event.jda) + .getGenericFailure(ConfigManager.config.getString("$SERVER_PATH.List.NotLinked")).toEmbed() ).queue() } } @@ -107,7 +107,7 @@ private class List(jda: JDA) : SimpleSubcommand( if (event.componentId.split(":")[2] != event.user.id) { event.replyEmbeds( EmbedManager.getGenericFailure(ConfigManager.config.getString("$SERVER_PATH.List.WrongUser")) - .toEmbed(event.jda) + .toEmbed() ) .setEphemeral(true).queue() return @@ -118,7 +118,7 @@ private class List(jda: JDA) : SimpleSubcommand( if (!pteroMember.isLinked()) { event.hook.sendMessageEmbeds( EmbedManager - .getGenericFailure(ConfigManager.config.getString("$SERVER_PATH.List.NotLinked")).toEmbed(event.jda) + .getGenericFailure(ConfigManager.config.getString("$SERVER_PATH.List.NotLinked")).toEmbed() ).setEphemeral(true).queue() return } @@ -127,7 +127,7 @@ private class List(jda: JDA) : SimpleSubcommand( } catch (exception: LoginException) { event.hook.sendMessageEmbeds( EmbedManager.getGenericFailure(ConfigManager.config.getString("$SERVER_PATH.List.WrongKey")) - .toEmbed(event.jda) + .toEmbed() ).queue() return } @@ -136,11 +136,11 @@ private class List(jda: JDA) : SimpleSubcommand( } catch (exception: ServerException) { event.hook.sendMessageEmbeds( EmbedManager.getGenericFailure(ConfigManager.config.getString("$SERVER_PATH.List.NodeOffline")) - .toEmbed(event.jda) + .toEmbed() ).queue() return } - val response = EmbedManager.getServerInfo(serverInfo).toEmbed(event.jda) + val response = EmbedManager.getServerInfo(serverInfo).toEmbed() val buttons = getButtons(server, serverInfo, event) event.hook.sendMessageEmbeds(response).addActionRow(buttons.subList(0, 5)) .addActionRow(buttons.subList(5, buttons.size)).queue() @@ -168,13 +168,13 @@ private class List(jda: JDA) : SimpleSubcommand( ConfigManager.config.getString( "$SERVER_PATH.List.SuccessStop" ) - ).toEmbed(event.jda) + ).toEmbed() ) .setEphemeral(true).queue() }) { buttonEvent.hook.sendMessageEmbeds( EmbedManager.getGenericFailure(ConfigManager.config.getString("Embeds.UnexpectedError")) - .toEmbed(event.jda) + .toEmbed() ) .setEphemeral(true).queue().also { _ -> logger.error("Error while changing server state !", it) @@ -196,13 +196,13 @@ private class List(jda: JDA) : SimpleSubcommand( ConfigManager.config.getString( "$SERVER_PATH.List.SuccessStart" ) - ).toEmbed(event.jda) + ).toEmbed() ) .setEphemeral(true).queue() }) { buttonEvent.hook.sendMessageEmbeds( EmbedManager.getGenericFailure(ConfigManager.config.getString("Messages.Embeds.UnexpectedError")) - .toEmbed(event.jda) + .toEmbed() ) .setEphemeral(true).queue().also { _ -> logger.error("Error while changing server state !", it) @@ -225,13 +225,13 @@ private class List(jda: JDA) : SimpleSubcommand( ConfigManager.config.getString( "$SERVER_PATH.List.SuccessRestart" ) - ).toEmbed(event.jda) + ).toEmbed() ) .setEphemeral(true).queue() }) { buttonEvent.hook.sendMessageEmbeds( EmbedManager.getGenericFailure(ConfigManager.config.getString("Embeds.UnexpectedError")) - .toEmbed(event.jda) + .toEmbed() ) .setEphemeral(true).queue().also { _ -> logger.error("Error while changing server state !", it) @@ -301,14 +301,14 @@ private class List(jda: JDA) : SimpleSubcommand( } catch (exception: ServerException) { it.editMessageEmbeds( EmbedManager.getGenericFailure(ConfigManager.config.getString("$SERVER_PATH.List.NodeOffline")) - .toEmbed(event.jda) + .toEmbed() ).setActionRow(closeButton).queue() return@cooldownButton } val newButtons = getButtons(serverNew, serverInfoNew, event) val rows = listOf(ActionRow.of(newButtons.subList(0, 5)), ActionRow.of(newButtons.subList(5, newButtons.size))) - it.editMessageEmbeds(EmbedManager.getServerInfo(serverInfoNew).toEmbed(event.jda)).setReplace(true) + it.editMessageEmbeds(EmbedManager.getServerInfo(serverInfoNew).toEmbed()).setReplace(true) .setComponents(rows).queue() } diff --git a/src/main/kotlin/tech/goksi/pterobot/manager/EmbedManager.kt b/src/main/kotlin/tech/goksi/pterobot/manager/EmbedManager.kt index 1d69e90..65268cd 100644 --- a/src/main/kotlin/tech/goksi/pterobot/manager/EmbedManager.kt +++ b/src/main/kotlin/tech/goksi/pterobot/manager/EmbedManager.kt @@ -1,18 +1,13 @@ package tech.goksi.pterobot.manager import dev.minn.jda.ktx.util.SLF4J -import net.dv8tion.jda.api.JDA import net.dv8tion.jda.api.entities.MessageEmbed -import net.dv8tion.jda.api.utils.data.DataObject -import net.dv8tion.jda.internal.JDAImpl -import net.dv8tion.jda.internal.utils.Helpers import tech.goksi.pterobot.EmbedType import tech.goksi.pterobot.entities.AccountInfo import tech.goksi.pterobot.entities.NodeInfo import tech.goksi.pterobot.entities.ServerInfo +import tech.goksi.pterobot.util.EmbedParser import java.io.File -import java.time.Instant -import java.time.format.DateTimeFormatter import kotlin.reflect.KProperty1 import kotlin.reflect.KVisibility @@ -75,12 +70,11 @@ object EmbedManager { val file = File(EmbedType.NODE_STATUS.path) file.readText() } - return rawServerStatus.replace("%timestamp", getCurrentTimestamp()) + return rawServerStatus.replace("%timestamp", getCurrentTimestamp().toString()) } - fun String.toEmbed(jda: JDA): MessageEmbed { - val jdaImpl: JDAImpl = jda as JDAImpl - return jdaImpl.entityBuilder.createMessageEmbed(DataObject.fromJson(this)) + fun String.toEmbed(): MessageEmbed { + return EmbedParser.parse(this) } private fun String.replacePlaceholders(replacements: Map): String { @@ -89,8 +83,7 @@ object EmbedManager { return result } - private fun getCurrentTimestamp(): String = - Helpers.toOffsetDateTime(Instant.now()).format(DateTimeFormatter.ISO_INSTANT) + private fun getCurrentTimestamp(): Long = System.currentTimeMillis() @Suppress("UNCHECKED_CAST") private fun getPlaceholderMap(entity: T): Map { @@ -98,7 +91,7 @@ object EmbedManager { .filterIsInstance>() .map { it as KProperty1 }.filter { it.visibility != KVisibility.PRIVATE } return buildMap { - this["%timestamp"] = getCurrentTimestamp() + this["%timestamp"] = getCurrentTimestamp().toString() fields.forEach { val value = when (val uncheckedVal = it.get(entity)) { is Float -> String.format("%.2f", uncheckedVal) diff --git a/src/main/kotlin/tech/goksi/pterobot/util/EmbedParser.kt b/src/main/kotlin/tech/goksi/pterobot/util/EmbedParser.kt new file mode 100644 index 0000000..728870c --- /dev/null +++ b/src/main/kotlin/tech/goksi/pterobot/util/EmbedParser.kt @@ -0,0 +1,42 @@ +package tech.goksi.pterobot.util + +import net.dv8tion.jda.api.EmbedBuilder +import net.dv8tion.jda.api.entities.MessageEmbed +import org.simpleyaml.configuration.file.YamlConfiguration +import java.time.Instant +import java.time.OffsetDateTime +import java.time.ZoneOffset + +object EmbedParser { + + fun parse(configString: String): MessageEmbed { + val config = YamlConfiguration.loadConfigurationFromString(configString) + val builder = EmbedBuilder() + builder.setTitle(config.getString("title")) + builder.setDescription(config.getString("description")) + var currentSection = config.getConfigurationSection("author") + builder.setAuthor( + currentSection?.getString("name"), + currentSection?.getString("url"), + currentSection?.getString("icon_url") + ) + builder.setColor(config.getInt("color")) + builder.setThumbnail(config.getString("thumbnail")) + builder.setImage(config.getString("image")) + currentSection = config.getConfigurationSection("fields") + if (currentSection != null) { + val fields = currentSection.getKeys(false).map { currentSection.getConfigurationSection(it) } + for (field in fields) { + builder.addField(field.getString("name"), field.getString("value"), field.getBoolean("inline")) + } + } + builder.setTimestamp( + if (config.getString("timestamp") == null) null + else OffsetDateTime.ofInstant(Instant.ofEpochMilli(config.getLong("timestamp")), ZoneOffset.UTC) + ) + currentSection = config.getConfigurationSection("footer") + builder.setFooter(currentSection.getString("text"), currentSection.getString("icon_url")) + + return builder.build() + } +} diff --git a/src/main/kotlin/tech/goksi/pterobot/util/cooldown/CooldownManager.kt b/src/main/kotlin/tech/goksi/pterobot/util/cooldown/CooldownManager.kt index 93efdb0..9b9fe76 100644 --- a/src/main/kotlin/tech/goksi/pterobot/util/cooldown/CooldownManager.kt +++ b/src/main/kotlin/tech/goksi/pterobot/util/cooldown/CooldownManager.kt @@ -32,7 +32,10 @@ object CooldownManager { private fun canInteract(event: ButtonInteractionEvent): Boolean = getRemaining(event) == 0L private fun getRemaining(event: ButtonInteractionEvent): Long = max( 0, - (cooldownMapping[CooldownNamespace(event.user.idLong, CooldownType.fromEvent(event))] ?: 0) - System.currentTimeMillis() + ( + cooldownMapping[CooldownNamespace(event.user.idLong, CooldownType.fromEvent(event))] + ?: 0 + ) - System.currentTimeMillis() ) private fun getRemainingSeconds(event: ButtonInteractionEvent): Long = @@ -58,7 +61,7 @@ object CooldownManager { EmbedManager.getGenericFailure( ConfigManager.config.getString("Messages.OnCooldown") .replace("%time", "${getRemainingSeconds(it)}") - ).toEmbed(it.jda) + ).toEmbed() ).setEphemeral(true).queue() return@onButton } diff --git a/src/main/resources/embeds/generic_error.json b/src/main/resources/embeds/generic_error.json deleted file mode 100644 index 5ae5f96..0000000 --- a/src/main/resources/embeds/generic_error.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "type": "IMAGE", - "author": { - "name": "PteroBot" - }, - "description": "%message", - "color": 16711680, - "image": { - "url": "" - }, - "thumbnail": { - "url": "" - }, - "footer": { - "icon_url": "https://images.g2crowd.com/uploads/product/image/social_landscape/social_landscape_9f7bed1018bc7ad75c94da92c83c76de/pterodactyl-panel.png", - "text": "PteroBot | Error" - } -} \ No newline at end of file diff --git a/src/main/resources/embeds/generic_error.yml b/src/main/resources/embeds/generic_error.yml new file mode 100644 index 0000000..4ac79b3 --- /dev/null +++ b/src/main/resources/embeds/generic_error.yml @@ -0,0 +1,7 @@ +description: %message +color: 16711680 +author: + name: PteroBot +footer: + text: PteroBot | Error + icon_url: https://images.g2crowd.com/uploads/product/image/social_landscape/social_landscape_9f7bed1018bc7ad75c94da92c83c76de/pterodactyl-panel.png \ No newline at end of file diff --git a/src/main/resources/embeds/generic_success.json b/src/main/resources/embeds/generic_success.json deleted file mode 100644 index e087c2b..0000000 --- a/src/main/resources/embeds/generic_success.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "type": "IMAGE", - "author": { - "name": "PteroBot" - }, - "description": "%message", - "color": 52084, - "image": { - "url": "" - }, - "thumbnail": { - "url": "" - }, - "footer": { - "icon_url": "https://images.g2crowd.com/uploads/product/image/social_landscape/social_landscape_9f7bed1018bc7ad75c94da92c83c76de/pterodactyl-panel.png", - "text": "PteroBot | Success" - } -} diff --git a/src/main/resources/embeds/generic_success.yml b/src/main/resources/embeds/generic_success.yml new file mode 100644 index 0000000..80df963 --- /dev/null +++ b/src/main/resources/embeds/generic_success.yml @@ -0,0 +1,7 @@ +description: %message +color: 52084 +author: + name: PteroBot +footer: + text: PteroBot | Success + icon_url: https://images.g2crowd.com/uploads/product/image/social_landscape/social_landscape_9f7bed1018bc7ad75c94da92c83c76de/pterodactyl-panel.png \ No newline at end of file diff --git a/src/main/resources/embeds/node_info.json b/src/main/resources/embeds/node_info.json deleted file mode 100644 index ea77bab..0000000 --- a/src/main/resources/embeds/node_info.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "type": "IMAGE", - "title": "Node info", - "color": 39129, - "fields": [ - { - "name": "Status", - "value": "%statusEmoji %status", - "inline": true - }, - { - "name": "Running servers", - "value": "%runningServers", - "inline": false - }, - { - "name": "Location", - "value": "%location", - "inline": true - }, - { - "name": "Maintenance mode ", - "value": "%maintenance", - "inline": true - }, - { - "name": "Allocations", - "value": "%allocationsCount", - "inline": true - }, - { - "name": "CPU usage", - "value": "%cpuUsed %", - "inline": false - }, - { - "name": "Disk usage", - "value": "%diskUsed GB / %diskLimit GB", - "inline": false - }, - { - "name": "Memory usage", - "value": "%ramUsed MB %memoryUsageBar %ramLimit MB", - "inline": false - } - ], - "footer": { - "icon_url": "https://images.g2crowd.com/uploads/product/image/social_landscape/social_landscape_9f7bed1018bc7ad75c94da92c83c76de/pterodactyl-panel.png", - "text": "PteroBot | Node" - }, - "author": { - "name": "PteroBot" - }, - "description": "%name\n%description", - "timestamp": "%timestamp" -} \ No newline at end of file diff --git a/src/main/resources/embeds/node_info.yml b/src/main/resources/embeds/node_info.yml new file mode 100644 index 0000000..6ab5cbd --- /dev/null +++ b/src/main/resources/embeds/node_info.yml @@ -0,0 +1,42 @@ +title: Node info +description: "%name\n%description" +color: 39129 +author: + name: PteroBot +fields: + f1: + name: Status + value: %statusEmoji %status + inline: true + f2: + name: Running servers + value: %runningServers + inline: false + f3: + name: Location + value: %location + inline: true + f4: + name: Maintenance mode + value: %maintenance + inline: true + f5: + name: Allocations + value: %allocationsCount + inline: true + f6: + name: CPU usage + value: %cpuUsed % + inline: false + f7: + name: Disk usage + value: %diskUsed GB / %diskLimit GB + inline: false + f8: + name: Memory usage + value: %ramUsed MB %memoryUsageBar %ramLimit MB + inline: false +footer: + text: PteroBot | Node + icon_url: https://images.g2crowd.com/uploads/product/image/social_landscape/social_landscape_9f7bed1018bc7ad75c94da92c83c76de/pterodactyl-panel.png +timestamp: %timestamp \ No newline at end of file diff --git a/src/main/resources/embeds/node_status.json b/src/main/resources/embeds/node_status.json deleted file mode 100644 index ec4ee1c..0000000 --- a/src/main/resources/embeds/node_status.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "type": "IMAGE", - "title": "PteroBot", - "author": { - "name": "PteroBot" - }, - "color": 39129, - "fields": [ - { - "name": "%nodeName", - "value": "%statusEmoji %status", - "inline": false - } - ], - "footer": { - "icon_url": "https://images.g2crowd.com/uploads/product/image/social_landscape/social_landscape_9f7bed1018bc7ad75c94da92c83c76de/pterodactyl-panel.png", - "text": "PteroBot | NodeStatus" - }, - "timestamp": "%timestamp" -} \ No newline at end of file diff --git a/src/main/resources/embeds/node_status.yml b/src/main/resources/embeds/node_status.yml new file mode 100644 index 0000000..4173e5e --- /dev/null +++ b/src/main/resources/embeds/node_status.yml @@ -0,0 +1,13 @@ +title: PteroBot +author: + name: PteroBot +color: 39129 +fields: + f1: # node status will always use template of first field for other nodes + name: %nodeName + value: %statusEmoji %status + inline: false +footer: + text: PteroBot | NodeStatus + icon_url: https://images.g2crowd.com/uploads/product/image/social_landscape/social_landscape_9f7bed1018bc7ad75c94da92c83c76de/pterodactyl-panel.png +timestamp: %timestamp \ No newline at end of file diff --git a/src/main/resources/embeds/server_info.json b/src/main/resources/embeds/server_info.json deleted file mode 100644 index 67bd9b5..0000000 --- a/src/main/resources/embeds/server_info.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "type": "IMAGE", - "color": 39129, - "author": { - "icon_url": "", - "name": "" - }, - "footer": { - "icon_url": "https://images.g2crowd.com/uploads/product/image/social_landscape/social_landscape_9f7bed1018bc7ad75c94da92c83c76de/pterodactyl-panel.png", - "text": "PteroBot | %identifier" - }, - "timestamp": "%timestamp", - "title": "PteroBot", - "description": "%name", - "fields": [ - { - "name": "Status", - "value": "%statusEmoji %status", - "inline": true - }, - { - "name": "Node", - "value": "%node", - "inline": true - }, - { - "name": "Allocation", - "value": "%allocationAlias", - "inline": false - }, - { - "name": "CPU usage", - "value": "%cpuUsed %", - "inline": true - }, - { - "name": "Disk usage", - "value": "%diskUsed GB / %diskMax GB", - "inline": true - }, - { - "name": "Memory usage", - "value": "%ramUsed MB %memoryUsageBar %ramLimit MB", - "inline": false - } - ] -} \ No newline at end of file diff --git a/src/main/resources/embeds/server_info.yml b/src/main/resources/embeds/server_info.yml new file mode 100644 index 0000000..bf1788a --- /dev/null +++ b/src/main/resources/embeds/server_info.yml @@ -0,0 +1,32 @@ +title: PteroBot +description: %name +color: 39129 +fields: + f1: + name: Status + value: %statusEmoji %status + inline: true + f2: + name: Node + value: %node, + inline: true + f3: + name: Allocation + value: %allocationAlias + inline: false + f4: + name: CPU usage + value: %cpuUsed % + inline: true + f5: + name: Disk usage + value: %diskUsed GB / %diskMax GB + inline: true + f6: + name: Memory usage + value: %ramUsed MB %memoryUsageBar %ramLimit MB + inline: false +footer: + text: PteroBot | %identifier + icon_url: https://images.g2crowd.com/uploads/product/image/social_landscape/social_landscape_9f7bed1018bc7ad75c94da92c83c76de/pterodactyl-panel.png +timestamp: %timestamp \ No newline at end of file diff --git a/src/main/resources/embeds/server_list.yml b/src/main/resources/embeds/server_list.yml new file mode 100644 index 0000000..e82b0b1 --- /dev/null +++ b/src/main/resources/embeds/server_list.yml @@ -0,0 +1,20 @@ +title: PteroBot +description: "Hello %username :wave:" +color: 39129 +fields: + f1: + name: Full name + value: %fullName + inline: true + f2: + name: Admin + value: %rootAdmin + inline: true + f3: + name: Email + value: %email + inline: false +footer: + text: PteroBot | Servers + icon_url: https://images.g2crowd.com/uploads/product/image/social_landscape/social_landscape_9f7bed1018bc7ad75c94da92c83c76de/pterodactyl-panel.png +timestamp: %timestamp \ No newline at end of file diff --git a/src/main/resources/embeds/servers_command.json b/src/main/resources/embeds/servers_command.json deleted file mode 100644 index 671c515..0000000 --- a/src/main/resources/embeds/servers_command.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "type": "IMAGE", - "description": "Hello %username :wave:", - "color": 39129, - "title": "PteroBot", - "footer": { - "text": "PteroBot | Servers", - "icon_url": "https://images.g2crowd.com/uploads/product/image/social_landscape/social_landscape_9f7bed1018bc7ad75c94da92c83c76de/pterodactyl-panel.png" - }, - "fields": [ - { - "name": "Full name", - "value": "%fullName", - "inline": true - }, - { - "name": "Admin", - "value": "%rootAdmin", - "inline": true - }, - { - "name": "Email", - "value": "%email", - "inline": false - } - ], - "timestamp": "%timestamp" -} \ No newline at end of file