From fc7edc0d0d05ede2bad6cec9e9e764b426535721 Mon Sep 17 00:00:00 2001 From: moonleay Date: Tue, 19 Dec 2023 10:28:49 +0100 Subject: [PATCH] feat!: improved MessageUtil Signed-off-by: moonleay --- .../net/moonleay/lilJudd/util/MessageUtil.kt | 74 +------------------ 1 file changed, 4 insertions(+), 70 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/util/MessageUtil.kt b/src/main/kotlin/net/moonleay/lilJudd/util/MessageUtil.kt index 6dfb545..3307f58 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/util/MessageUtil.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/util/MessageUtil.kt @@ -18,10 +18,7 @@ package net.moonleay.lilJudd.util -import com.kotlindiscord.kord.extensions.commands.Arguments -import com.kotlindiscord.kord.extensions.commands.application.slash.PublicSlashCommandContext -import com.kotlindiscord.kord.extensions.components.forms.ModalForm -import com.kotlindiscord.kord.extensions.types.respond +import dev.kord.core.behavior.UserBehavior import dev.kord.core.entity.Embed import dev.kord.rest.builder.message.EmbedBuilder import java.time.LocalDateTime @@ -30,44 +27,9 @@ import java.time.format.DateTimeFormatter object MessageUtil { private val dtf: DateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy @ HH:mm:ss") - ///Send an embedded message as a reply - suspend fun sendEmbedForPublicSlashCommand( - ctx: PublicSlashCommandContext, - color: EmbedColor, - title: String, - description: String - ) { - ctx.respond { - embeds.add( - getEmbed( - color, - title, - description, - ctx.user.asUser().username + "#" + ctx.user.asUser().discriminator - ) - ) - } - } - - ///Send an embedded message with an image as a reply - suspend fun sendEmbedForPublicSlashCommandWithImage( - ctx: PublicSlashCommandContext, - color: EmbedColor, - title: String, - description: String, - thumbnailUrl: String - ) { - ctx.respond { - embeds.add( - getEmbedWithImage( - color, - title, - description, - ctx.user.asUser().username + "#" + ctx.user.asUser().discriminator, - thumbnailUrl - ) - ) - } + suspend fun getFooter(u: UserBehavior? = null): String { + val now: LocalDateTime = LocalDateTime.now() + return ">" + dtf.format(now) + " - ${u?.asUser()?.username ?: "Automated Message"}" } ///Get a cloned embedded message @@ -101,20 +63,6 @@ object MessageUtil { return ebb } - fun getEmbedWithTableWithFooter( - color: EmbedColor, - title: String, - description: String, - values: Map>?, - footer: String - ): EmbedBuilder { - val ebb = getEmbedWithTable(color, title, description, values) - ebb.footer = EmbedBuilder.Footer() - ebb.footer!!.text = ">m.id/$footer" - return ebb - } - - ///Get an embedded msg with image, title and description fun getEmbedWithTable( color: EmbedColor, title: String, @@ -136,7 +84,6 @@ object MessageUtil { return ebb } - ///Get an embedded msg with title and description fun getEmbedSmall( color: EmbedColor, @@ -164,17 +111,4 @@ object MessageUtil { return ebb } - ///Get an embedded msg with image, title, description and a src - fun getEmbedWithImage( - color: EmbedColor, - title: String, - description: String, - source: String, - thumbnailUrl: String - ): EmbedBuilder { - val ebb = getEmbed(color, title, description, source) - ebb.thumbnail = EmbedBuilder.Thumbnail() - ebb.thumbnail!!.url = thumbnailUrl - return ebb - } }