Skip to content

Commit

Permalink
Small fixes, don't get application info on every data collection
Browse files Browse the repository at this point in the history
  • Loading branch information
gdude2002 committed Aug 9, 2024
1 parent 0ea7648 commit 8a71d34
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ public open class ExtensibleBotBuilder {
* configuration to a subcommand named "general".
*/
public fun section(body: Section.() -> Unit) {
val section = Section()
val section = Section(this)

body(section)

Expand Down Expand Up @@ -711,12 +711,12 @@ public open class ExtensibleBotBuilder {
public var emoji: ReactionEmoji? = null
}

public class Section {
public class Section(parent: AboutBuilder) {
public lateinit var name: String
public lateinit var description: String
public lateinit var messageBuilder: suspend MessageCreateBuilder.() -> Unit

public var bundle: String? = null
public var bundle: String? = parent.translationBundle

public fun message(body: suspend MessageCreateBuilder.() -> Unit) {
messageBuilder = body
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

package dev.kordex.core.datacollection

import dev.kord.core.entity.Application
import dev.kord.gateway.Intents
import dev.kordex.core.*
import dev.kordex.core.annotations.InternalAPI
Expand Down Expand Up @@ -44,9 +45,15 @@ public class DataCollector(public val level: DataCollection) : KordExKoinCompone
private val state: Properties = loadState()
private val systemInfo by lazy { SystemInfo() }

private lateinit var applicationInfo: Application

@OptIn(InternalAPI::class)
@Suppress("TooGenericExceptionCaught")
internal suspend fun collect() {
if (!::applicationInfo.isInitialized) {
applicationInfo = bot.kordRef.getApplicationInfo()
}

try {
lateinit var entity: Entity
val lastUUID = getUUID()
Expand Down Expand Up @@ -78,7 +85,7 @@ public class DataCollector(public val level: DataCollection) : KordExKoinCompone
},

botId = bot.kordRef.selfId.toString(),
botName = bot.kordRef.getApplicationInfo().name,
botName = applicationInfo.name,
extensionCount = bot.extensions.size,
guildCount = bot.kordRef.guilds.count(),

Expand All @@ -95,8 +102,6 @@ public class DataCollector(public val level: DataCollection) : KordExKoinCompone
val hardware = systemInfo.hardware
val processor = hardware.processor

val applicationInfo = bot.kordRef.getApplicationInfo()

entity = ExtraDataEntity(
id = lastUUID,

Expand Down

0 comments on commit 8a71d34

Please sign in to comment.