Skip to content

Commit

Permalink
refactor: Rename jda var to shardManager
Browse files Browse the repository at this point in the history
  • Loading branch information
WinG4merBR committed Jan 8, 2025
1 parent 7b9ef85 commit dfa52cf
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions foxy/src/main/kotlin/net/cakeyfox/foxy/FoxyInstance.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -59,7 +59,7 @@ class FoxyInstance(
}

mongoClient.start(this)
jda = DefaultShardManagerBuilder.create(
shardManager = DefaultShardManagerBuilder.create(
GatewayIntent.GUILD_MEMBERS,
GatewayIntent.MESSAGE_CONTENT,
GatewayIntent.GUILD_MESSAGES,
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class FoxyCommandManager(private val foxy: FoxyInstance) {

suspend fun handle(): MutableList<Command> {
val allCommands = mutableListOf<Command>()
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 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit dfa52cf

Please sign in to comment.