Skip to content

Commit 0d2167a

Browse files
author
Racci
committed
style: Update style to ktlint standards
1 parent b2bd753 commit 0d2167a

File tree

15 files changed

+200
-191
lines changed

15 files changed

+200
-191
lines changed

src/main/kotlin/dev/racci/elixir/ElixirBot.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,22 @@ import dev.racci.elixir.database.DatabaseManager
1313
import dev.racci.elixir.events.JoinLeaveEvent
1414
import dev.racci.elixir.events.LogEvents
1515
import dev.racci.elixir.events.MessageEvents
16+
import dev.racci.elixir.extensions.RoleSelector
1617
import dev.racci.elixir.extensions.StatChannels
1718
import dev.racci.elixir.extensions.commands.moderation.Moderation
1819
import dev.racci.elixir.extensions.commands.moderation.Report
1920
import dev.racci.elixir.extensions.commands.util.Custom
2021
import dev.racci.elixir.extensions.commands.util.Github
2122
import dev.racci.elixir.extensions.commands.util.Ping
22-
import dev.racci.elixir.extensions.RoleSelector
2323
import dev.racci.elixir.support.ThreadInviter
2424
import dev.racci.elixir.utils.BOT_TOKEN
2525
import dev.racci.elixir.utils.CONFIG_PATH
2626
import dev.racci.elixir.utils.GITHUB_OAUTH
2727
import dev.racci.elixir.utils.GUILD_ID
2828
import dev.racci.elixir.utils.SENTRY_DSN
29+
import mu.KotlinLogging
30+
import org.kohsuke.github.GitHub
31+
import org.kohsuke.github.GitHubBuilder
2932
import java.nio.file.Files
3033
import java.nio.file.Path
3134
import java.nio.file.Paths
@@ -82,7 +85,6 @@ suspend fun main() {
8285
sentry {
8386
enableIfDSN(SENTRY_DSN)
8487
}
85-
8688
}
8789

8890
hooks {
@@ -99,7 +101,7 @@ suspend fun main() {
99101
@Suppress("BlockingMethodInNonBlockingContext")
100102
github = GitHubBuilder().withOAuthToken(GITHUB_OAUTH).build()
101103
gitHubLogger.info("Logged into GitHub!")
102-
} catch(exception: Exception) {
104+
} catch (exception: Exception) {
103105
exception.printStackTrace()
104106
gitHubLogger.error("Failed to log into GitHub!")
105107
throw Exception(exception)

src/main/kotlin/dev/racci/elixir/database/DatabaseManager.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import com.zaxxer.hikari.HikariConfig
44
import com.zaxxer.hikari.HikariDataSource
55
import dev.racci.elixir.utils.JDBC_URL
66
import io.ktor.utils.io.errors.IOException
7-
import java.nio.file.Files
8-
import java.nio.file.Path
97
import mu.KotlinLogging
108
import org.jetbrains.exposed.sql.Database
119
import org.jetbrains.exposed.sql.SchemaUtils
1210
import org.jetbrains.exposed.sql.Table
1311
import org.jetbrains.exposed.sql.transactions.transaction
12+
import java.nio.file.Files
13+
import java.nio.file.Path
1414

1515
/**
1616
* The Database system within the bot
@@ -35,34 +35,33 @@ object DatabaseManager {
3535
logger.info("Connected to database.")
3636
}
3737

38-
object Warn: Table("warn") {
38+
object Warn : Table("warn") {
3939

4040
val id = text("id")
4141
val points = text("points").nullable()
4242

4343
override val primaryKey = PrimaryKey(id)
4444
}
4545

46-
object RoleSelector: Table("role_selector") {
46+
object RoleSelector : Table("role_selector") {
4747

4848
val name = text("name")
4949
val messageId = long("messageId")
5050
val channelId = long("channelId")
5151

5252
override val primaryKey = PrimaryKey(name)
53-
5453
}
5554

5655
fun startDatabase() {
5756
try {
5857
val database = Path.of("database.db")
5958

60-
if(Files.notExists(database)) {
59+
if (Files.notExists(database)) {
6160
Files.createFile(database)
6261

6362
logger.info("Created database file.")
6463
}
65-
} catch(e: IOException) {
64+
} catch (e: IOException) {
6665
e.printStackTrace()
6766
}
6867

src/main/kotlin/dev/racci/elixir/events/JoinLeaveEvent.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ import dev.kord.core.behavior.channel.createEmbed
1212
import dev.kord.core.event.guild.MemberJoinEvent
1313
import dev.kord.core.event.guild.MemberLeaveEvent
1414
import dev.racci.elixir.utils.JOIN_CHANNEL
15-
import kotlin.time.ExperimentalTime
1615
import kotlinx.coroutines.flow.count
1716
import kotlinx.datetime.Clock
17+
import kotlin.time.ExperimentalTime
1818

1919
/**
2020
* The join and leave logging for Members in the guild. More accurate join and leave times for users
2121
* @author NoComment1105
2222
*/
23-
class JoinLeaveEvent: Extension() {
23+
class JoinLeaveEvent : Extension() {
2424

2525
override val name = "joinleaveevent"
2626

@@ -91,4 +91,4 @@ class JoinLeaveEvent: Extension() {
9191
}
9292
}
9393
}
94-
}
94+
}

src/main/kotlin/dev/racci/elixir/events/LogEvents.kt

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import kotlinx.datetime.Clock
2121
import kotlinx.datetime.TimeZone
2222
import kotlinx.datetime.periodUntil
2323

24-
class LogEvents: Extension() {
24+
class LogEvents : Extension() {
2525

2626
override val name = "LogEvents"
2727

@@ -30,7 +30,7 @@ class LogEvents: Extension() {
3030

3131
event<MessageDeleteEvent> {
3232
action {
33-
if(event.message?.asMessageOrNull()?.author?.isBot == true) return@action
33+
if (event.message?.asMessageOrNull()?.author?.isBot == true) return@action
3434
val messageContent = event.message?.asMessageOrNull()?.content.toString()
3535
val eventMessage = event.message
3636
val messageLocation = event.channel.id.value
@@ -64,14 +64,14 @@ class LogEvents: Extension() {
6464
sentry.breadcrumb(BreadcrumbType.Info) {
6565
category = "events.messageevents.MessageDeleted"
6666
message = "A message was deleted"
67-
data["content"] = messageContent.ifEmpty {"Failed to get content of message"}
67+
data["content"] = messageContent.ifEmpty { "Failed to get content of message" }
6868
}
6969
}
7070
}
7171

7272
event<MessageUpdateEvent> {
7373
action {
74-
if(event.message.asMessageOrNull()?.author?.isBot == true) return@action
74+
if (event.message.asMessageOrNull()?.author?.isBot == true) return@action
7575
val messageContentBefore = event.old?.content.toString()
7676
val messageContentAfter = event.new.content.toString()
7777
val eventMessage = event.message.asMessageOrNull()
@@ -119,8 +119,8 @@ class LogEvents: Extension() {
119119
sentry.breadcrumb(BreadcrumbType.Info) {
120120
category = "events.LogEvents.MessageUpdated"
121121
message = "A message was updated"
122-
data["oldContent"] = messageContentBefore.ifEmpty {"Failed to get content of message"}
123-
data["newContent"] = messageContentAfter.ifEmpty {"Failed to get content of message"}
122+
data["oldContent"] = messageContentBefore.ifEmpty { "Failed to get content of message" }
123+
data["newContent"] = messageContentAfter.ifEmpty { "Failed to get content of message" }
124124
}
125125
}
126126
}
@@ -259,8 +259,5 @@ class LogEvents: Extension() {
259259
}
260260
}
261261
}
262-
263262
}
264-
265-
266-
}
263+
}

src/main/kotlin/dev/racci/elixir/events/MessageEvents.kt

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ import io.ktor.client.HttpClient
2323
import io.ktor.client.request.post
2424
import io.ktor.client.statement.HttpResponse
2525
import io.ktor.util.cio.toByteArray
26+
import kotlinx.datetime.Clock
2627
import java.io.ByteArrayInputStream
2728
import java.util.zip.GZIPInputStream
2829
import kotlin.time.ExperimentalTime
29-
import kotlinx.datetime.Clock
3030

31-
class MessageEvents: Extension() {
31+
class MessageEvents : Extension() {
3232

3333
override val name = "messageevents"
3434

@@ -45,11 +45,11 @@ class MessageEvents: Extension() {
4545
action {
4646
val eventMessage = event.message.asMessageOrNull()
4747

48-
eventMessage.attachments.forEach {attachment->
48+
eventMessage.attachments.forEach { attachment ->
4949
val attachmentFileName = attachment.filename
5050
val attachmentFileExtension = attachmentFileName.substring(attachmentFileName.lastIndexOf(".") + 1)
5151

52-
if(attachmentFileExtension in LOG_FILE_EXTENSIONS) {
52+
if (attachmentFileExtension in LOG_FILE_EXTENSIONS) {
5353
var confirmationMessage: Message? = null
5454

5555
confirmationMessage = ResponseHelper.responseEmbedInChannel(
@@ -69,7 +69,7 @@ class MessageEvents: Extension() {
6969
category = "events.messageevents.loguploading.uploadAccept"
7070
message = "Upload accepted"
7171
}
72-
if(event.interaction.user.id == eventMessage.author?.id) {
72+
if (event.interaction.user.id == eventMessage.author?.id) {
7373
confirmationMessage!!.delete()
7474

7575
val uploadMessage = eventMessage.channel.createEmbed {
@@ -88,7 +88,7 @@ class MessageEvents: Extension() {
8888

8989
val builder = StringBuilder()
9090

91-
if(attachmentFileExtension != "gz") {
91+
if (attachmentFileExtension != "gz") {
9292
builder.append(logBytes.decodeToString())
9393
} else {
9494
val bis = ByteArrayInputStream(logBytes)
@@ -117,11 +117,13 @@ class MessageEvents: Extension() {
117117
}
118118
}
119119
}
120-
} catch(e: Exception) {
120+
} catch (e: Exception) {
121121
uploadMessage.edit {
122-
ResponseHelper.failureEmbed(event.interaction.getChannel(),
122+
ResponseHelper.failureEmbed(
123+
event.interaction.getChannel(),
123124
"Failed to upload `$attachmentFileName` to Hastebin",
124-
e.toString())
125+
e.toString()
126+
)
125127
}
126128
sentry.breadcrumb(BreadcrumbType.Error) {
127129
category = "events.messageevnets.loguploading.UploadTask"
@@ -142,7 +144,7 @@ class MessageEvents: Extension() {
142144
style = ButtonStyle.Secondary
143145

144146
action {
145-
if(event.interaction.user.id == eventMessage.author?.id) {
147+
if (event.interaction.user.id == eventMessage.author?.id) {
146148
confirmationMessage!!.delete()
147149
sentry.breadcrumb(BreadcrumbType.Info) {
148150
category = "events.messagevents.loguploading.uploadDeny"
@@ -171,13 +173,15 @@ class MessageEvents: Extension() {
171173
body = text
172174
}.content.toByteArray().decodeToString()
173175

174-
if(response.contains("\"key\"")) {
175-
response = "https://www.toptal.com/developers/hastebin/" + response.substring(response.indexOf(":") + 2,
176-
response.length - 2)
176+
if (response.contains("\"key\"")) {
177+
response = "https://www.toptal.com/developers/hastebin/" + response.substring(
178+
response.indexOf(":") + 2,
179+
response.length - 2
180+
)
177181
}
178182

179183
client.close()
180184

181185
return response
182186
}
183-
}
187+
}

0 commit comments

Comments
 (0)