diff --git a/build.gradle.kts b/build.gradle.kts index b51ade74..2c99945c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,7 +12,7 @@ plugins { } group = "org.hyacinthbots.lilybot" -version = "4.1.0" +version = "4.1.1" repositories { mavenCentral() @@ -53,14 +53,12 @@ dependencies { implementation(libs.kord.extensions) implementation(libs.kord.extensions.phishing) - implementation(libs.kord.extensions.mappings) implementation(libs.kord.extensions.pluralkit) implementation(libs.kord.extensions.unsafe) implementation(libs.kotlin.stdlib) // Logging dependencies - implementation(libs.groovy) implementation(libs.logback) implementation(libs.logging) diff --git a/docs/changelogs/4.1.1.md b/docs/changelogs/4.1.1.md new file mode 100644 index 00000000..1184c825 --- /dev/null +++ b/docs/changelogs/4.1.1.md @@ -0,0 +1,19 @@ +# LilyBot 4.1.1 + +This release cleans up quite a few errors and small missing features from the 4.1.0 release. +It also temporarily removes reminders as they are completely broken and need to be re-written. +Lastly, it removes the KordEx Mappings extension as Lily is no longer a Minecraft-focused bot. + +Change: +* remove reminders +* remove mappings extension +* switch to xml for logback +* add a jump button to edit logging +* no longer log edited messages from bots + +Fix: +* message edits going to member log +* Lily's online embed in production +* message attachments on message edit and delete logs + +You can find a list of all the commits in this update [here](https://github.com/hyacinthbots/LilyBot/compare/v4.1.0...v4.1.1) diff --git a/libs.versions.toml b/libs.versions.toml index c63d5b72..8b5d06ad 100644 --- a/libs.versions.toml +++ b/libs.versions.toml @@ -1,20 +1,17 @@ [versions] kotlin = "1.7.10" # Note: Plugin versions must be updated in the settings.gradle.kts too -groovy = "3.0.13" kord-extensions = "1.5.5-20220925.092000-32" -logging = "2.1.23" # Cannot be updated to 3.0.0 because we need newer logback, which requires an XML file, which throws errors I cannot fix -logback = "1.2.8" +logging = "3.0.0" +logback = "1.4.1" github-api = "1.313" kmongo = "4.7.1" detekt = "1.21.0" koma = "1.1.0" [libraries] -groovy = { module = "org.codehaus.groovy:groovy", version.ref = "groovy" } kord-extensions = { module = "com.kotlindiscord.kord.extensions:kord-extensions", version.ref = "kord-extensions" } kord-extensions-phishing = { module = "com.kotlindiscord.kord.extensions:extra-phishing", version.ref = "kord-extensions" } -kord-extensions-mappings = { module = "com.kotlindiscord.kord.extensions:extra-mappings", version.ref = "kord-extensions"} kord-extensions-pluralkit = { module = "com.kotlindiscord.kord.extensions:extra-pluralkit", version.ref = "kord-extensions"} kord-extensions-unsafe = { module = "com.kotlindiscord.kord.extensions:unsafe", version.ref = "kord-extensions"} kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8" } diff --git a/src/main/kotlin/org/hyacinthbots/lilybot/LilyBot.kt b/src/main/kotlin/org/hyacinthbots/lilybot/LilyBot.kt index d7a65e4f..4b72c81e 100644 --- a/src/main/kotlin/org/hyacinthbots/lilybot/LilyBot.kt +++ b/src/main/kotlin/org/hyacinthbots/lilybot/LilyBot.kt @@ -5,7 +5,6 @@ package org.hyacinthbots.lilybot import cc.ekblad.toml.decode import cc.ekblad.toml.tomlMapper import com.kotlindiscord.kord.extensions.ExtensibleBot -import com.kotlindiscord.kord.extensions.modules.extra.mappings.extMappings import com.kotlindiscord.kord.extensions.modules.extra.phishing.DetectionAction import com.kotlindiscord.kord.extensions.modules.extra.phishing.extPhishing import com.kotlindiscord.kord.extensions.modules.extra.pluralkit.extPluralKit @@ -107,8 +106,6 @@ suspend fun main() { requiredCommandPermission = null } - extMappings { } // Enable the mappings extension - extPluralKit() sentry { diff --git a/src/main/kotlin/org/hyacinthbots/lilybot/extensions/events/MessageEdit.kt b/src/main/kotlin/org/hyacinthbots/lilybot/extensions/events/MessageEdit.kt index 278134bf..e095f969 100644 --- a/src/main/kotlin/org/hyacinthbots/lilybot/extensions/events/MessageEdit.kt +++ b/src/main/kotlin/org/hyacinthbots/lilybot/extensions/events/MessageEdit.kt @@ -2,15 +2,19 @@ package org.hyacinthbots.lilybot.extensions.events import com.kotlindiscord.kord.extensions.DISCORD_YELLOW import com.kotlindiscord.kord.extensions.checks.anyGuild +import com.kotlindiscord.kord.extensions.components.components +import com.kotlindiscord.kord.extensions.components.linkButton import com.kotlindiscord.kord.extensions.extensions.Extension import com.kotlindiscord.kord.extensions.extensions.event import com.kotlindiscord.kord.extensions.modules.extra.pluralkit.api.PKMessage import com.kotlindiscord.kord.extensions.modules.extra.pluralkit.events.ProxiedMessageUpdateEvent import com.kotlindiscord.kord.extensions.modules.extra.pluralkit.events.UnProxiedMessageUpdateEvent +import com.kotlindiscord.kord.extensions.utils.getJumpUrl import dev.kord.core.behavior.channel.asChannelOf -import dev.kord.core.behavior.channel.createEmbed +import dev.kord.core.behavior.channel.createMessage import dev.kord.core.entity.Message import dev.kord.core.entity.channel.GuildMessageChannel +import dev.kord.rest.builder.message.create.embed import kotlinx.datetime.Clock import org.hyacinthbots.lilybot.extensions.config.ConfigOptions import org.hyacinthbots.lilybot.utils.attachmentsAndProxiedMessageInfo @@ -37,7 +41,8 @@ class MessageEdit : Extension() { anyGuild() requiredConfigs(ConfigOptions.MESSAGE_EDIT_LOGGING_ENABLED, ConfigOptions.MESSAGE_LOG) failIf { - event.message.asMessage().author?.id == kord.selfId + val message = event.message.asMessage() + message.author?.isBot == true || event.old?.content == message.content } } action { @@ -55,7 +60,7 @@ class MessageEdit : Extension() { anyGuild() requiredConfigs(ConfigOptions.MESSAGE_EDIT_LOGGING_ENABLED, ConfigOptions.MESSAGE_LOG) failIf { - event.message.asMessage().author?.id == kord.selfId + event.old?.content == event.message.asMessage().content } } action { @@ -77,28 +82,36 @@ class MessageEdit : Extension() { val messageLog = getLoggingChannelWithPerms(ConfigOptions.MESSAGE_LOG, guild) ?: return - messageLog.createEmbed { - color = DISCORD_YELLOW - author { - name = "Message Edited" - icon = proxiedMessage?.member?.avatarUrl ?: message.author?.avatar?.url - } - description = - "Location: ${message.channel.mention} " + - "(${message.channel.asChannelOf().name})" - timestamp = Clock.System.now() + messageLog.createMessage { + embed { + color = DISCORD_YELLOW + author { + name = "Message Edited" + icon = proxiedMessage?.member?.avatarUrl ?: message.author?.avatar?.url + } + description = + "Location: ${message.channel.mention} " + + "(${message.channel.asChannelOf().name})" + timestamp = Clock.System.now() - field { - name = "Previous contents" - value = old?.trimmedContents().ifNullOrEmpty { "Failed to retrieve previous message contents" } - inline = false + field { + name = "Previous contents" + value = old?.trimmedContents().ifNullOrEmpty { "Failed to retrieve previous message contents" } + inline = false + } + field { + name = "New contents" + value = message.trimmedContents().ifNullOrEmpty { "Failed to retrieve new message contents" } + inline = false + } + attachmentsAndProxiedMessageInfo(guild, message, proxiedMessage) } - field { - name = "New contents" - value = message.trimmedContents().ifNullOrEmpty { "Failed to retrieve new message contents" } - inline = false + components { + linkButton { + label = "Jump" + url = message.getJumpUrl() + } } - attachmentsAndProxiedMessageInfo(guild, message, proxiedMessage) } } } diff --git a/src/main/kotlin/org/hyacinthbots/lilybot/extensions/util/GalleryChannel.kt b/src/main/kotlin/org/hyacinthbots/lilybot/extensions/util/GalleryChannel.kt index b69508f5..2ba42705 100644 --- a/src/main/kotlin/org/hyacinthbots/lilybot/extensions/util/GalleryChannel.kt +++ b/src/main/kotlin/org/hyacinthbots/lilybot/extensions/util/GalleryChannel.kt @@ -12,7 +12,6 @@ import com.kotlindiscord.kord.extensions.extensions.event import com.kotlindiscord.kord.extensions.types.respond import com.kotlindiscord.kord.extensions.utils.delete import com.kotlindiscord.kord.extensions.utils.respond -import com.soywiz.klock.seconds import dev.kord.common.entity.MessageType import dev.kord.common.entity.Permission import dev.kord.common.entity.Permissions @@ -25,6 +24,7 @@ import org.hyacinthbots.lilybot.database.collections.GalleryChannelCollection import org.hyacinthbots.lilybot.extensions.config.ConfigOptions import org.hyacinthbots.lilybot.utils.botHasChannelPerms import org.hyacinthbots.lilybot.utils.getLoggingChannelWithPerms +import kotlin.time.Duration.Companion.seconds /** * The class the holds the systems that allow a guild to set a channel as a gallery channel. @@ -187,7 +187,7 @@ class GalleryChannel : Extension() { // If there are no attachments to the message and the channel we're in is an image channel if (event.message.channelId == it.channelId && event.message.attachments.isEmpty()) { // We delay to give the message a chance to populate with an embed, if it is a link to imgur etc. - delay(0.25.seconds.millisecondsLong) + delay(0.25.seconds.inWholeMilliseconds) if (event.message.embeds.isEmpty()) { // If there is still no embed, we delete the message // and explain why if (event.message.type != MessageType.Default && event.message.type != MessageType.Reply) { @@ -204,7 +204,7 @@ class GalleryChannel : Extension() { try { // Delete the explanation after 3 seconds. If an exception is thrown, the // message has already been deleted - response.delete(2.5.seconds.millisecondsLong) + response.delete(2.5.seconds.inWholeMilliseconds) } catch (e: EntityNotFoundException) { // The message that we're attempting to delete has already been deleted. } diff --git a/src/main/kotlin/org/hyacinthbots/lilybot/utils/_Utils.kt b/src/main/kotlin/org/hyacinthbots/lilybot/utils/_Utils.kt index 2e113744..99c245e9 100644 --- a/src/main/kotlin/org/hyacinthbots/lilybot/utils/_Utils.kt +++ b/src/main/kotlin/org/hyacinthbots/lilybot/utils/_Utils.kt @@ -647,7 +647,7 @@ suspend fun EmbedBuilder.attachmentsAndProxiedMessageInfo( if (message.attachments.isNotEmpty()) { field { name = "Attachments" - value = message.attachments.map { it.url }.joinToString { "\n" } + value = message.attachments.joinToString(separator = "\n") { it.url } inline = false } } diff --git a/src/main/resources/logback.groovy b/src/main/resources/logback.groovy deleted file mode 100644 index b12de689..00000000 --- a/src/main/resources/logback.groovy +++ /dev/null @@ -1,14 +0,0 @@ -import ch.qos.logback.core.joran.spi.ConsoleTarget - -// Silence warning about missing native PRNG -logger("io.ktor.util.random", ERROR) - -appender("CONSOLE", ConsoleAppender) { - encoder(PatternLayoutEncoder) { - pattern = "%boldMagenta(%d{dd-MM-yyyy HH:mm:ss}) %gray(|) %boldCyan(%-30.-30thread) %gray(|) %highlight(%-5level) %gray(|) %boldGreen(%-40.40logger{40}) %gray(|) %msg%n" - } - - target = ConsoleTarget.SystemErr -} - -root(INFO, ["CONSOLE"]) diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 00000000..765be676 --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,15 @@ + + + + + + + + %boldMagenta(%d{dd-MM-yyyy HH:mm:ss}) %gray(|) %boldCyan(%-30.-30thread) %gray(|) %highlight(%-5level) %gray(|) %boldGreen(%-40.40logger{40}) %gray(|) %msg%n + + + + + + +