ktlint (again)
This commit is contained in:
parent
dc14e3ee1e
commit
23afb34a97
|
@ -14,9 +14,9 @@ application {
|
||||||
tasks.withType<Jar> {
|
tasks.withType<Jar> {
|
||||||
manifest {
|
manifest {
|
||||||
attributes(
|
attributes(
|
||||||
mapOf(
|
mapOf(
|
||||||
"Main-Class" to botMainClass
|
"Main-Class" to botMainClass
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,10 @@ package moe.kageru.kagebot
|
||||||
|
|
||||||
import java.time.ZoneId
|
import java.time.ZoneId
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
import java.util.logging.*
|
import java.util.logging.FileHandler
|
||||||
|
import java.util.logging.Formatter
|
||||||
|
import java.util.logging.LogRecord
|
||||||
|
import java.util.logging.Logger
|
||||||
|
|
||||||
object Log {
|
object Log {
|
||||||
val log: Logger by lazy {
|
val log: Logger by lazy {
|
||||||
|
@ -17,7 +20,7 @@ object Log {
|
||||||
|
|
||||||
private class LogFormatter : Formatter() {
|
private class LogFormatter : Formatter() {
|
||||||
private val timeFormatter: DateTimeFormatter =
|
private val timeFormatter: DateTimeFormatter =
|
||||||
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault())
|
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault())
|
||||||
|
|
||||||
override fun format(record: LogRecord): String {
|
override fun format(record: LogRecord): String {
|
||||||
return "[${record.level}] ${timeFormatter.format(record.instant)}: ${record.message}\n"
|
return "[${record.level}] ${timeFormatter.format(record.instant)}: ${record.message}\n"
|
||||||
|
|
|
@ -10,7 +10,7 @@ import org.javacord.api.entity.permission.Role
|
||||||
import org.javacord.api.entity.user.User
|
import org.javacord.api.entity.user.User
|
||||||
import org.javacord.api.event.message.MessageCreateEvent
|
import org.javacord.api.event.message.MessageCreateEvent
|
||||||
import java.awt.Color
|
import java.awt.Color
|
||||||
import java.util.*
|
import java.util.Optional
|
||||||
import java.util.concurrent.CompletableFuture
|
import java.util.concurrent.CompletableFuture
|
||||||
import java.util.concurrent.CompletionException
|
import java.util.concurrent.CompletionException
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ object Util {
|
||||||
* Mimics the behavior of [Optional.ifPresent], but returns null if the optional is empty,
|
* Mimics the behavior of [Optional.ifPresent], but returns null if the optional is empty,
|
||||||
* allowing easier fallback behavior via Kotlin’s ?: operator.
|
* allowing easier fallback behavior via Kotlin’s ?: operator.
|
||||||
*/
|
*/
|
||||||
inline fun <T, R> Optional<T>.ifNotEmpty(op: (T) -> R): R? {
|
private inline fun <T, R> Optional<T>.ifNotEmpty(op: (T) -> R): R? {
|
||||||
if (this.isPresent) {
|
if (this.isPresent) {
|
||||||
return op(this.get())
|
return op(this.get())
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,4 +34,3 @@ class MessageActions(rawActions: RawMessageActions) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@ class RawCommand(
|
||||||
val response: String?,
|
val response: String?,
|
||||||
val matchType: String?,
|
val matchType: String?,
|
||||||
val permissions: RawPermissions?,
|
val permissions: RawPermissions?,
|
||||||
@SerializedName("action") val actions: RawMessageActions?,
|
@SerializedName("action")
|
||||||
|
val actions: RawMessageActions?,
|
||||||
val embed: List<String>?,
|
val embed: List<String>?,
|
||||||
val feature: String?
|
val feature: String?
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,13 +7,15 @@ import java.io.File
|
||||||
class RawConfig(
|
class RawConfig(
|
||||||
val system: RawSystemConfig?,
|
val system: RawSystemConfig?,
|
||||||
val localization: RawLocalization?,
|
val localization: RawLocalization?,
|
||||||
@SerializedName("command") val commands: List<RawCommand>?,
|
@SerializedName("command")
|
||||||
@SerializedName("feature") val features: RawFeatures?
|
val commands: List<RawCommand>?,
|
||||||
|
@SerializedName("feature")
|
||||||
|
val features: RawFeatures?
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
const val DEFAULT_CONFIG_PATH = "config.toml"
|
private const val DEFAULT_CONFIG_PATH = "config.toml"
|
||||||
|
|
||||||
fun readFromString(tomlContent: String) = Toml().read(tomlContent).to(RawConfig::class.java)
|
fun readFromString(tomlContent: String): RawConfig = Toml().read(tomlContent).to(RawConfig::class.java)
|
||||||
|
|
||||||
fun read(path: String = DEFAULT_CONFIG_PATH): RawConfig {
|
fun read(path: String = DEFAULT_CONFIG_PATH): RawConfig {
|
||||||
val toml: Toml = Toml().read(run {
|
val toml: Toml = Toml().read(run {
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.javacord.api.entity.message.embed.EmbedBuilder
|
||||||
import org.javacord.api.entity.user.User
|
import org.javacord.api.entity.user.User
|
||||||
import org.javacord.api.event.message.MessageCreateEvent
|
import org.javacord.api.event.message.MessageCreateEvent
|
||||||
import org.javacord.core.entity.message.embed.EmbedBuilderDelegateImpl
|
import org.javacord.core.entity.message.embed.EmbedBuilderDelegateImpl
|
||||||
import java.util.*
|
import java.util.Optional
|
||||||
|
|
||||||
object TestUtil {
|
object TestUtil {
|
||||||
fun mockMessage(
|
fun mockMessage(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user