Skip to content

Commit

Permalink
fixed a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
FireBall1725 committed Jun 29, 2024
1 parent 6e41fc7 commit 081e15a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package ca.fireball1725.lcs.discordbot.listeners

import ca.fireball1725.lcs.discordbot.botConfig
import ca.fireball1725.lcs.discordbot.tasks.InviteProcessor
import ca.fireball1725.lcs.discordbot.tasks.MembersProcessor
import ca.fireball1725.lcs.discordbot.whitelist.WhitelistProcessor
import dev.kord.core.event.guild.MemberJoinEvent
import dev.kord.core.event.message.MessageCreateEvent
Expand All @@ -28,4 +29,6 @@ fun registerListeners() =
on<MemberJoinEvent> { InviteProcessor().memberJoinEvent(this) } // refresh invite codes
on<MessageCreateEvent> { InviteProcessor().channelMessageEvent(this) } // check for invite metadata message
}

on<MemberJoinEvent> { MembersProcessor().updateMembersTable() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,15 @@ class Pterodactyl(

val response = client.newCall(request).execute()

if (response.code != 200) {
return null
}

if (response.body == null) {
return null
}

val directoryList = Gson().fromJson(response.body!!.string(), GetDirectoryList::class.java)
response.use { // use statement ensures the response is closed
if (response.code != 200) {
return null
}

response.close()
response.body ?: return null

return directoryList
return Gson().fromJson(response.body!!.string(), GetDirectoryList::class.java)
}
}

fun getFileContents(
Expand All @@ -99,19 +95,17 @@ class Pterodactyl(

val response = client.newCall(request).execute()

if (response.code != 200) {
return null
}

if (response.body == null) {
return null
}

val fileContents = response.body!!.string()
response.use { // use statement ensures the response is closed
if (response.code != 200) {
return null
}

response.close()
val responseBody = response.body ?: return null

return fileContents
return responseBody.string()
}
}

fun getServerBackup(serverId: String): GetWorldBackup? {
Expand All @@ -128,19 +122,15 @@ class Pterodactyl(

val response = client.newCall(request).execute()

if (response.code != 200) {
return null
}

if (response.body == null) {
return null
}

val downloadBackupResponse = Gson().fromJson(response.body!!.string(), GetWorldBackup::class.java)
response.use { // use statement ensures the response is closed
if (response.code != 200) {
return null
}

response.close()
val responseBody = response.body ?: return null

return downloadBackupResponse
return Gson().fromJson(responseBody.string(), GetWorldBackup::class.java)
}
}

fun getDownloadBackup(
Expand All @@ -160,19 +150,17 @@ class Pterodactyl(

val response = client.newCall(request).execute()

if (response.code != 200) {
return null
}

if (response.body == null) {
return null
}
response.use { // use statement ensures the response is closed
if (response.code != 200) {
return null
}

val downloadBackupResponse = Gson().fromJson(response.body!!.string(), GetDownloadBackup::class.java)
response.body ?: return null

response.close()
val downloadBackupResponse = Gson().fromJson(response.body!!.string(), GetDownloadBackup::class.java)

return downloadBackupResponse.downloadBackupAttributes!!.url
return downloadBackupResponse.downloadBackupAttributes!!.url
}
}

private fun processRequest(request: Request): Response {
Expand Down

0 comments on commit 081e15a

Please sign in to comment.