From dfa52cfc6cfb42d539d6493169d148fb93997a98 Mon Sep 17 00:00:00 2001 From: WinG4merBR <68250074+WinG4merBR@users.noreply.github.com> Date: Wed, 8 Jan 2025 03:04:20 -0300 Subject: [PATCH] refactor: Rename `jda` var to `shardManager` --- foxy/src/main/kotlin/net/cakeyfox/foxy/FoxyInstance.kt | 8 ++++---- .../net/cakeyfox/foxy/command/FoxyCommandManager.kt | 4 ++-- .../foxy/command/component/FoxyComponentManager.kt | 2 +- .../net/cakeyfox/foxy/modules/antiraid/AntiRaidModule.kt | 4 ++-- .../kotlin/net/cakeyfox/foxy/utils/ActivityUpdater.kt | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/foxy/src/main/kotlin/net/cakeyfox/foxy/FoxyInstance.kt b/foxy/src/main/kotlin/net/cakeyfox/foxy/FoxyInstance.kt index 7f4bef9f..b1689f72 100644 --- a/foxy/src/main/kotlin/net/cakeyfox/foxy/FoxyInstance.kt +++ b/foxy/src/main/kotlin/net/cakeyfox/foxy/FoxyInstance.kt @@ -29,7 +29,7 @@ import kotlin.reflect.jvm.jvmName class FoxyInstance( val config: FoxyConfig ) { - lateinit var jda: ShardManager + lateinit var shardManager: ShardManager lateinit var mongoClient: MongoDBClient lateinit var commandHandler: FoxyCommandManager lateinit var artistryClient: ArtistryClient @@ -59,7 +59,7 @@ class FoxyInstance( } mongoClient.start(this) - jda = DefaultShardManagerBuilder.create( + shardManager = DefaultShardManagerBuilder.create( GatewayIntent.GUILD_MEMBERS, GatewayIntent.MESSAGE_CONTENT, GatewayIntent.GUILD_MESSAGES, @@ -84,12 +84,12 @@ class FoxyInstance( this.commandHandler.handle() - selfUser = jda.getShardById(0)?.selfUser!! + selfUser = shardManager.getShardById(0)?.selfUser!! Runtime.getRuntime().addShutdownHook(thread(false) { try { logger.info { "Foxy is shutting down..." } - jda.shards.forEach { shard -> + shardManager.shards.forEach { shard -> shard.removeEventListener(*shard.registeredListeners.toTypedArray()) logger.info { "Shutting down shard #${shard.shardInfo.shardId}..."} shard.shutdown() diff --git a/foxy/src/main/kotlin/net/cakeyfox/foxy/command/FoxyCommandManager.kt b/foxy/src/main/kotlin/net/cakeyfox/foxy/command/FoxyCommandManager.kt index e85ec3ba..15f4f35c 100644 --- a/foxy/src/main/kotlin/net/cakeyfox/foxy/command/FoxyCommandManager.kt +++ b/foxy/src/main/kotlin/net/cakeyfox/foxy/command/FoxyCommandManager.kt @@ -33,8 +33,8 @@ class FoxyCommandManager(private val foxy: FoxyInstance) { suspend fun handle(): MutableList { val allCommands = mutableListOf() - logger.info { "Starting command handling for ${foxy.jda.shards.size + 1} shards" } - foxy.jda.shards.forEach { shard -> + logger.info { "Starting command handling for ${foxy.shardManager.shards.size + 1} shards" } + foxy.shardManager.shards.forEach { shard -> val action = shard.updateCommands() commands.forEach { command -> diff --git a/foxy/src/main/kotlin/net/cakeyfox/foxy/command/component/FoxyComponentManager.kt b/foxy/src/main/kotlin/net/cakeyfox/foxy/command/component/FoxyComponentManager.kt index 5559e409..c0c188a4 100644 --- a/foxy/src/main/kotlin/net/cakeyfox/foxy/command/component/FoxyComponentManager.kt +++ b/foxy/src/main/kotlin/net/cakeyfox/foxy/command/component/FoxyComponentManager.kt @@ -112,7 +112,7 @@ class FoxyComponentManager( style, ComponentId(buttonId).toString(), label, - emoji?.let { foxy.jda.getEmojiById(it) } + emoji?.let { foxy.shardManager.getEmojiById(it) } ).let { ButtonBuilder(it).apply(builder).button } diff --git a/foxy/src/main/kotlin/net/cakeyfox/foxy/modules/antiraid/AntiRaidModule.kt b/foxy/src/main/kotlin/net/cakeyfox/foxy/modules/antiraid/AntiRaidModule.kt index 6bff2c72..ac270c7c 100644 --- a/foxy/src/main/kotlin/net/cakeyfox/foxy/modules/antiraid/AntiRaidModule.kt +++ b/foxy/src/main/kotlin/net/cakeyfox/foxy/modules/antiraid/AntiRaidModule.kt @@ -269,7 +269,7 @@ class AntiRaidModule( alertsSent.put(targetId, Unit) val message = WarningBuilder().apply(block) - val channel = foxy.jda.getTextChannelById(channelId) ?: return + val channel = foxy.shardManager.getTextChannelById(channelId) ?: return val msg = MessageCreateBuilder { embed { title = pretty( @@ -299,7 +299,7 @@ class AntiRaidModule( private suspend fun sendAlertToUser(channelId: String, userId: String, block: InlineMessage<*>.() -> Unit) { if (userAlertsSent.getIfPresent(userId) != null) return userAlertsSent.put(userId, Unit) - val channel = foxy.jda.getTextChannelById(channelId) ?: return + val channel = foxy.shardManager.getTextChannelById(channelId) ?: return val msg = MessageCreateBuilder { apply(block) } diff --git a/foxy/src/main/kotlin/net/cakeyfox/foxy/utils/ActivityUpdater.kt b/foxy/src/main/kotlin/net/cakeyfox/foxy/utils/ActivityUpdater.kt index 432045d1..5aaa6726 100644 --- a/foxy/src/main/kotlin/net/cakeyfox/foxy/utils/ActivityUpdater.kt +++ b/foxy/src/main/kotlin/net/cakeyfox/foxy/utils/ActivityUpdater.kt @@ -45,7 +45,7 @@ class ActivityUpdater( return@post } - foxy.jda.shards.forEach { + foxy.shardManager.shards.forEach { request.status?.let { OnlineStatus.fromKey(it) } ?: OnlineStatus.ONLINE Activity.of( ActivityType.fromKey(request.type),