Compare commits

..

No commits in common. "a2dafa5c7229628cf887076342ac46a94634d795" and "32da9ac7af44454e575403e19b24ca19d970844c" have entirely different histories.

15 changed files with 237 additions and 229 deletions

View file

@ -34,12 +34,12 @@ version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_
?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" } ?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" }
?: "2.6.7" ?: "2.6.7"
val kordver = "1.7.1-SNAPSHOT" val kordver = "1.5.9-SNAPSHOT"
val coroutinesver = "1.7.3" val coroutinesver = "1.7.3"
val ktorver = "2.3.7" val ktorver = "2.3.5"
val exposedver = "0.45.0" val exposedver = "0.43.0"
val postgresver = "42.7.1" val postgresver = "42.6.0"
val krontabver = "2.2.4" val krontabver = "2.2.1"
val mavenArtifact = "lilJudd" val mavenArtifact = "lilJudd"
project.base.archivesName.set(mavenArtifact) project.base.archivesName.set(mavenArtifact)
@ -105,8 +105,8 @@ dependencies {
//Krontab //Krontab
shadow("dev.inmo:krontab:$krontabver") shadow("dev.inmo:krontab:$krontabver")
shadow("io.ktor:ktor-client-core-jvm:$ktorver") shadow("io.ktor:ktor-client-core-jvm:2.3.5")
shadow("io.ktor:ktor-client-cio-jvm:$ktorver") shadow("io.ktor:ktor-client-cio-jvm:2.3.5")
} }

View file

@ -25,8 +25,7 @@ import dev.kord.core.entity.Guild
import dev.kord.core.entity.User import dev.kord.core.entity.User
import dev.kord.core.entity.channel.MessageChannel import dev.kord.core.entity.channel.MessageChannel
import dev.kord.core.entity.interaction.ButtonInteraction import dev.kord.core.entity.interaction.ButtonInteraction
import dev.kord.rest.builder.message.EmbedBuilder import dev.kord.rest.builder.message.modify.embed
import dev.kord.rest.builder.message.embed
import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.Bot
import net.moonleay.lilJudd.buttons.component.IEditButton import net.moonleay.lilJudd.buttons.component.IEditButton
import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository
@ -90,13 +89,13 @@ class AcceptEditButton() : IEditButton {
if (shouldEditButton) { if (shouldEditButton) {
// update the message // update the message
Bot.bot.kordRef.getChannelOf<MessageChannel>(interaction.channelId)!!.getMessage(m.id).edit { Bot.bot.kordRef.getChannelOf<MessageChannel>(interaction.channelId)!!.getMessage(m.id).edit {
this.embed(fun EmbedBuilder.() { this.embed {
color = eb.color this.color = eb.color
title = eb.title this.title = eb.title
description = eb.description this.description = eb.description
fields = eb.fields this.fields = eb.fields
footer = eb.footer this.footer = eb.footer
}) }
} }
} }
} }

View file

@ -25,8 +25,7 @@ import dev.kord.core.entity.Guild
import dev.kord.core.entity.User import dev.kord.core.entity.User
import dev.kord.core.entity.channel.MessageChannel import dev.kord.core.entity.channel.MessageChannel
import dev.kord.core.entity.interaction.ButtonInteraction import dev.kord.core.entity.interaction.ButtonInteraction
import dev.kord.rest.builder.message.EmbedBuilder import dev.kord.rest.builder.message.modify.embed
import dev.kord.rest.builder.message.embed
import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.Bot
import net.moonleay.lilJudd.buttons.component.IEditButton import net.moonleay.lilJudd.buttons.component.IEditButton
import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository
@ -63,14 +62,14 @@ class CancelEditButton : IEditButton {
member.removeRole(role.id) member.removeRole(role.id)
} }
Bot.bot.kordRef.getChannelOf<MessageChannel>(interaction.channelId)!!.getMessage(m.id).edit { Bot.bot.kordRef.getChannelOf<MessageChannel>(interaction.channelId)!!.getMessage(m.id).edit {
this.embed(fun EmbedBuilder.() { this.embed {
val temp = EmbedUtil.replaceXWithYinValuesAtTable(user.id.value.toString(), "", m.embeds[0], 1) val temp = EmbedUtil.replaceXWithYinValuesAtTable(user.id.value.toString(), "", m.embeds[0], 1)
color = temp.color this.color = temp.color
title = temp.title this.title = temp.title
description = temp.description this.description = temp.description
fields = temp.fields this.fields = temp.fields
footer = temp.footer this.footer = temp.footer
}) }
} }
} }
} }

View file

@ -25,8 +25,7 @@ import dev.kord.core.entity.Guild
import dev.kord.core.entity.User import dev.kord.core.entity.User
import dev.kord.core.entity.channel.MessageChannel import dev.kord.core.entity.channel.MessageChannel
import dev.kord.core.entity.interaction.ButtonInteraction import dev.kord.core.entity.interaction.ButtonInteraction
import dev.kord.rest.builder.message.EmbedBuilder import dev.kord.rest.builder.message.modify.embed
import dev.kord.rest.builder.message.embed
import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.Bot
import net.moonleay.lilJudd.buttons.component.IEditButton import net.moonleay.lilJudd.buttons.component.IEditButton
import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository
@ -90,13 +89,13 @@ class DeclineEditButton : IEditButton {
if (shouldEditButton) { if (shouldEditButton) {
// update the message // update the message
Bot.bot.kordRef.getChannelOf<MessageChannel>(interaction.channelId)!!.getMessage(m.id).edit { Bot.bot.kordRef.getChannelOf<MessageChannel>(interaction.channelId)!!.getMessage(m.id).edit {
this.embed(fun EmbedBuilder.() { this.embed {
color = eb.color this.color = eb.color
title = eb.title this.title = eb.title
description = eb.description this.description = eb.description
fields = eb.fields this.fields = eb.fields
footer = eb.footer this.footer = eb.footer
}) }
} }
} }
} }

View file

@ -24,7 +24,7 @@ import dev.kord.core.entity.Guild
import dev.kord.core.entity.User import dev.kord.core.entity.User
import dev.kord.core.entity.channel.MessageChannel import dev.kord.core.entity.channel.MessageChannel
import dev.kord.core.entity.interaction.ButtonInteraction import dev.kord.core.entity.interaction.ButtonInteraction
import dev.kord.rest.builder.message.embed import dev.kord.rest.builder.message.modify.embed
import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.Bot
import net.moonleay.lilJudd.buttons.component.IEditButton import net.moonleay.lilJudd.buttons.component.IEditButton
import net.moonleay.lilJudd.features.AvailabilityManager import net.moonleay.lilJudd.features.AvailabilityManager

View file

@ -24,7 +24,7 @@ import dev.kord.core.entity.Guild
import dev.kord.core.entity.User import dev.kord.core.entity.User
import dev.kord.core.entity.channel.MessageChannel import dev.kord.core.entity.channel.MessageChannel
import dev.kord.core.entity.interaction.ButtonInteraction import dev.kord.core.entity.interaction.ButtonInteraction
import dev.kord.rest.builder.message.embed import dev.kord.rest.builder.message.modify.embed
import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.Bot
import net.moonleay.lilJudd.buttons.component.IEditButton import net.moonleay.lilJudd.buttons.component.IEditButton
import net.moonleay.lilJudd.features.AvailabilityManager import net.moonleay.lilJudd.features.AvailabilityManager

View file

@ -24,7 +24,7 @@ import dev.kord.core.entity.Guild
import dev.kord.core.entity.User import dev.kord.core.entity.User
import dev.kord.core.entity.channel.MessageChannel import dev.kord.core.entity.channel.MessageChannel
import dev.kord.core.entity.interaction.ButtonInteraction import dev.kord.core.entity.interaction.ButtonInteraction
import dev.kord.rest.builder.message.embed import dev.kord.rest.builder.message.modify.embed
import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.Bot
import net.moonleay.lilJudd.buttons.component.IEditButton import net.moonleay.lilJudd.buttons.component.IEditButton
import net.moonleay.lilJudd.features.AvailabilityManager import net.moonleay.lilJudd.features.AvailabilityManager

View file

@ -23,9 +23,9 @@ import com.kotlindiscord.kord.extensions.commands.application.slash.converters.i
import com.kotlindiscord.kord.extensions.commands.converters.impl.channel import com.kotlindiscord.kord.extensions.commands.converters.impl.channel
import com.kotlindiscord.kord.extensions.extensions.Extension import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import com.kotlindiscord.kord.extensions.utils.hasPermission import com.kotlindiscord.kord.extensions.utils.hasPermission
import dev.kord.common.entity.Permission import dev.kord.common.entity.Permission
import dev.kord.rest.builder.message.embed
import net.moonleay.lilJudd.extensions.component.EnableOrDisable import net.moonleay.lilJudd.extensions.component.EnableOrDisable
import net.moonleay.lilJudd.features.component.FeatureEnum import net.moonleay.lilJudd.features.component.FeatureEnum
import net.moonleay.lilJudd.features.component.FeatureManager import net.moonleay.lilJudd.features.component.FeatureManager
@ -49,16 +49,14 @@ class FeatureManageExtension : Extension() {
val u = this.user val u = this.user
if (!u.asMember(this.guild!!.id).hasPermission(Permission.Administrator)) { if (!u.asMember(this.guild!!.id).hasPermission(Permission.Administrator)) {
this.respond { this.respond {
this.embed { embeds.add(
this.color = EmbedColor.ERROR.color MessageUtil.getEmbed(
this.title = "403: Forbidden" EmbedColor.ERROR,
this.description = "403: Forbidden",
"You cannot edit features, as you don't have the Administrator permission." "You cannot edit features, as you don't have the Administrator permission.",
this.footer { u.asUser().username + "#" + u.asUser().discriminator
this.icon = u.asUser().avatar?.cdnUrl?.toUrl() )
this.text = MessageUtil.getFooter(u) )
}
}
} }
return@action return@action
} }
@ -70,45 +68,26 @@ class FeatureManageExtension : Extension() {
val f = FeatureManager.getFeature(args.feature) val f = FeatureManager.getFeature(args.feature)
if (f == null) { if (f == null) {
this.respond { this.respond {
this.embed { this.embeds.add(
this.color = EmbedColor.ERROR.color MessageUtil.getEmbed(
this.title = "404: Not Found" EmbedColor.ERROR,
this.description = "The feature you are trying to edit does not exist." "404: Not Found",
this.footer { "The feature you are trying to edit does not exist.",
this.icon = u.asUser().avatar?.cdnUrl?.toUrl() u.asUser().username + "#" + u.asUser().discriminator
this.text = MessageUtil.getFooter(u) )
} )
}
} }
return@action return@action
} }
if (this.arguments.setStatus == EnableOrDisable.ENABLE) { if (this.arguments.setStatus == EnableOrDisable.ENABLE) {
val enabled = f.enable(u, gID, cID, channel, args)
this.respond { this.respond {
this.embed { this.embeds.add(f.enable(u, gID, cID, channel, args))
this.color = enabled.color
this.title = enabled.title
this.description = enabled.description
this.footer {
this.icon = u.asUser().avatar?.cdnUrl?.toUrl()
this.text = MessageUtil.getFooter(u)
}
}
} }
return@action return@action
} }
val disabled = f.disable(u, gID, cID, channel, args)
this.respond { this.respond {
this.embed { this.embeds.add(f.disable(u, gID, cID, channel, args))
this.color = disabled.color
this.title = disabled.title
this.description = disabled.description
this.footer {
this.icon = u.asUser().avatar?.cdnUrl?.toUrl()
this.text = MessageUtil.getFooter(u)
}
}
} }
} }
} }

View file

@ -20,8 +20,8 @@ package net.moonleay.lilJudd.extensions
import com.kotlindiscord.kord.extensions.extensions.Extension import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
import dev.kord.rest.builder.message.embed
import net.moonleay.lilJudd.util.EmbedColor import net.moonleay.lilJudd.util.EmbedColor
import net.moonleay.lilJudd.util.MessageUtil
import net.moonleay.liljudd.build.BuildConstants import net.moonleay.liljudd.build.BuildConstants
class InfoExtension : Extension() { class InfoExtension : Extension() {
@ -31,17 +31,16 @@ class InfoExtension : Extension() {
name = "info" name = "info"
description = "Show infos about the bot" description = "Show infos about the bot"
this.action { this.action {
this.respond { MessageUtil.sendEmbedForPublicSlashCommand(
this.embed { this,
this.color = EmbedColor.INFO.color EmbedColor.INFO,
this.title = "Li'l Judd" "Lil' Judd",
this.description = "Li'l Judd ***v." + BuildConstants.version + "***\n" + "Lil' Judd ***v." + BuildConstants.version + "***\n" +
"Kord-Extensions ***v." + BuildConstants.kordVersion + "***\n" + "Kord-Extensions ***v." + BuildConstants.kordVersion + "***\n" +
"Coroutines ***v." + BuildConstants.coroutinesVersion + "***\n" + "Coroutines ***v." + BuildConstants.coroutinesVersion + "***\n" +
"Krontab ***v." + BuildConstants.krontabVersion + "***\n\n" + "Krontab ***v." + BuildConstants.krontabVersion + "***\n\n" +
"Splatoon 3 api data provided by splatoon3.ink" "Splatoon 3 api data provided by splatoon3.ink"
} )
}
} }
} }
} }

View file

@ -23,9 +23,9 @@ import com.kotlindiscord.kord.extensions.commands.application.slash.converters.i
import com.kotlindiscord.kord.extensions.commands.converters.impl.string import com.kotlindiscord.kord.extensions.commands.converters.impl.string
import com.kotlindiscord.kord.extensions.extensions.Extension import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import dev.kord.core.behavior.createRole import dev.kord.core.behavior.createRole
import dev.kord.rest.builder.message.actionRow import dev.kord.rest.builder.message.create.actionRow
import dev.kord.rest.builder.message.embed
import net.moonleay.lilJudd.data.database.entry.MatchPlanningDataData import net.moonleay.lilJudd.data.database.entry.MatchPlanningDataData
import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository import net.moonleay.lilJudd.data.database.repository.MatchPlanningDataRepository
import net.moonleay.lilJudd.extensions.component.MatchTypes import net.moonleay.lilJudd.extensions.component.MatchTypes
@ -55,16 +55,15 @@ class MatchExtension : Extension() {
val opponent = args.opponent val opponent = args.opponent
if (!TimeUtil.validateDateString(args.timeStamp)) { if (!TimeUtil.validateDateString(args.timeStamp)) {
this.respond { this.respond {
this.embed { this.embeds.add(
this.color = EmbedColor.ERROR.color MessageUtil.getEmbed(
this.title = "400: Bad Request" EmbedColor.ERROR,
this.description = "The given timestamp is invalid.\n" + "400: Bad Request",
"Please use the format \"dd.MM.yyyy HH:mm\"." "The given timestamp is invalid.\n" +
this.footer { "Please use the format \"dd.MM.yyyy HH:mm\".",
this.icon = m.asUser().avatar?.cdnUrl?.toUrl() m.asUser().username
this.text = MessageUtil.getFooter(m.asUser()) )
} )
}
} }
return@action return@action
} }
@ -81,41 +80,32 @@ class MatchExtension : Extension() {
// Check if the role was created successfully // Check if the role was created successfully
if (role == null) { if (role == null) {
this.respond { this.respond {
this.embed { this.embeds.add(
this.color = EmbedColor.ERROR.color MessageUtil.getEmbed(
this.title = "500: Internal Error" EmbedColor.ERROR,
this.description = "Could not find created role.\n" + "500: Internal Error",
"It seems, that said role could not be created." "Could not find created role.\n" +
this.footer { "It seems, that said role could not be created.",
this.icon = m.asUser().avatar?.cdnUrl?.toUrl() m.asUser().username
this.text = MessageUtil.getFooter(m.asUser()) )
} )
}
} }
return@action return@action
} }
val msg = this.respond { val msg = this.respond {
val eb = MessageUtil.getEmbedWithTable( this.embeds.add(
EmbedColor.INFO, MessageUtil.getEmbedWithTable(
args.matchType.readableName, EmbedColor.INFO,
"***Vs. $opponent***\n" + args.matchType.readableName,
"At ${args.timeStamp}\n" + "***Vs. $opponent***\n" +
"Registered by ${m.mention}", "At ${args.timeStamp}\n" +
mapOf( "Registered by ${m.mention}",
"Signed up" to listOf(), mapOf(
"Unavailable" to listOf(), "Signed up" to listOf(),
"Unavailable" to listOf(),
)
) )
) )
this.embed {
this.color = eb.color
this.title = eb.title
this.description = eb.description
this.fields = eb.fields
this.footer {
this.icon = m.asUser().avatar?.cdnUrl?.toUrl()
this.text = MessageUtil.getFooter(m.asUser())
}
}
this.actionRow { this.actionRow {
this.components.addAll(EmbedUtil.getMatchButtons().components) this.components.addAll(EmbedUtil.getMatchButtons().components)

View file

@ -20,13 +20,12 @@ package net.moonleay.lilJudd.extensions
import com.kotlindiscord.kord.extensions.extensions.Extension import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import com.kotlindiscord.kord.extensions.utils.hasPermission import com.kotlindiscord.kord.extensions.utils.hasPermission
import dev.kord.common.entity.Permission import dev.kord.common.entity.Permission
import dev.kord.core.behavior.channel.createMessage import dev.kord.core.behavior.channel.createMessage
import dev.kord.rest.builder.message.actionRow import dev.kord.rest.builder.message.create.actionRow
import dev.kord.rest.builder.message.embed
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import net.moonleay.lilJudd.Bot
import net.moonleay.lilJudd.data.database.entry.TimePlanningMessagesData import net.moonleay.lilJudd.data.database.entry.TimePlanningMessagesData
import net.moonleay.lilJudd.data.database.repository.TimePlanningMessagesRepository import net.moonleay.lilJudd.data.database.repository.TimePlanningMessagesRepository
import net.moonleay.lilJudd.util.* import net.moonleay.lilJudd.util.*
@ -65,40 +64,30 @@ class SendPlannerExtension : Extension() {
.withHour(4) .withHour(4)
.withMinute(0).withSecond(0) .withMinute(0).withSecond(0)
c.createMessage { c.createMessage {
this.embed { this.embeds.add(
this.color = EmbedColor.INFO.color MessageUtil.getEmbed(
this.title = "Time Planning Feature" EmbedColor.INFO,
this.description = "Do you have time on the following Days?" "Time Planning Feature",
this.footer { "Do you have time on the following Days?",
this.icon = Bot.bot.kordRef.getSelf().avatar?.cdnUrl?.toUrl() "Automated Message"
this.text = MessageUtil.getFooter() )
} )
}
} }
delay(1000) delay(1000)
repeat(7) { repeat(7) {
val eb = MessageUtil.getEmbedWithTable(
EmbedColor.INFO,
"",
"${then.dayOfWeek.name}, ${then.dayOfMonth}.${then.monthValue}.${then.year} /${it + 1}. weekday",
mapOf(
"Is available" to listOf(),
"May be available" to listOf(),
"Is not available" to listOf()
)
)
val msg = c.createMessage { val msg = c.createMessage {
this.embed { this.embeds.add(
this.color = eb.color MessageUtil.getEmbedWithTable(
this.title = eb.title EmbedColor.INFO,
this.description = eb.description "",
this.fields = eb.fields "${then.dayOfWeek.name}, ${then.dayOfMonth}.${then.monthValue}.${then.year} /${it + 1}. weekday",
this.footer { mapOf(
this.icon = Bot.bot.kordRef.getSelf().avatar?.cdnUrl?.toUrl() "Is available" to listOf(),
this.text = MessageUtil.getFooter() "May be available" to listOf(),
} "Is not available" to listOf()
} )
)
)
this.actionRow { this.actionRow {
this.components.addAll(EmbedUtil.getTimePlannerButtons().components) this.components.addAll(EmbedUtil.getTimePlannerButtons().components)

View file

@ -20,9 +20,9 @@ package net.moonleay.lilJudd.extensions
import com.kotlindiscord.kord.extensions.extensions.Extension import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
import com.kotlindiscord.kord.extensions.types.respond
import com.kotlindiscord.kord.extensions.utils.hasPermission import com.kotlindiscord.kord.extensions.utils.hasPermission
import dev.kord.common.entity.Permission import dev.kord.common.entity.Permission
import dev.kord.rest.builder.message.embed
import net.moonleay.lilJudd.features.AvailabilityManager import net.moonleay.lilJudd.features.AvailabilityManager
import net.moonleay.lilJudd.util.EmbedColor import net.moonleay.lilJudd.util.EmbedColor
import net.moonleay.lilJudd.util.Logger import net.moonleay.lilJudd.util.Logger
@ -42,31 +42,30 @@ class UpdateRolesExtension : Extension() {
.hasPermission(Permission.Administrator) .hasPermission(Permission.Administrator)
) { ) {
this.respond { this.respond {
this.embed { this.embeds.add(
this.color = EmbedColor.ERROR.color MessageUtil.getEmbed(
this.title = "403: Forbidden" EmbedColor.ERROR,
this.description = "403: Forbidden",
"You cannot update roles, as you don't have the Administrator permission." "You need to be an administrator to use this command.",
this.footer { user.asUser().username + "#" + user.asUser().discriminator
this.icon = user.asUser().avatar?.cdnUrl?.toUrl() )
this.text = MessageUtil.getFooter(user) )
}
}
} }
return@action return@action
} }
this.respond { this.respond {
this.embed { this.embeds.add(
this.color = EmbedColor.INFO.color MessageUtil.getEmbed(
this.title = "200: Success" EmbedColor.SUCCESS,
this.description = "Updating roles.\n" + "200: Success",
"This may take a while, please be patient." "Updating roles.\n" +
this.footer { "This may take a while, please be patient.",
this.icon = user.asUser().avatar?.cdnUrl?.toUrl() user.asUser().username + "#" + user.asUser().discriminator
this.text = MessageUtil.getFooter(user) )
} )
}
} }
// -- below here is the code of the cronjob --
Logger.out("Starting to update roles...") Logger.out("Starting to update roles...")
AvailabilityManager.updateInChannel(this.channel.id) AvailabilityManager.updateInChannel(this.channel.id)

View file

@ -26,8 +26,7 @@ import dev.kord.core.behavior.channel.createMessage
import dev.kord.core.entity.channel.Channel import dev.kord.core.entity.channel.Channel
import dev.kord.core.entity.channel.MessageChannel import dev.kord.core.entity.channel.MessageChannel
import dev.kord.rest.builder.message.EmbedBuilder import dev.kord.rest.builder.message.EmbedBuilder
import dev.kord.rest.builder.message.actionRow import dev.kord.rest.builder.message.create.actionRow
import dev.kord.rest.builder.message.embed
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.Bot
import net.moonleay.lilJudd.data.database.entry.TimePlanningChannelsData import net.moonleay.lilJudd.data.database.entry.TimePlanningChannelsData
@ -79,53 +78,43 @@ object TimeManager : IFeature {
c.createMessage { c.createMessage {
this.content = this.content =
"The weekly planning starts now <@&${Snowflake(targetedRoles[ch2]?.wantsToBeNotifiedID!!)}>" "The weekly planning starts now <@&${Snowflake(targetedRoles[ch2]?.wantsToBeNotifiedID!!)}>"
this.embed { this.embeds.add(
this.color = EmbedColor.INFO.color MessageUtil.getEmbed(
this.title = "Time Planning Feature" EmbedColor.INFO,
this.description = "Do you have time on the following Days?" "Time Planning Feature",
this.footer { "Do you have time on the following Days?",
this.icon = Bot.bot.kordRef.getSelf().avatar?.cdnUrl?.toUrl() "Automated Message"
this.text = MessageUtil.getFooter() )
} )
}
} }
} else { } else {
c.createMessage { c.createMessage {
this.embed { this.embeds.add(
this.color = EmbedColor.INFO.color MessageUtil.getEmbed(
this.title = "Time Planning Feature" EmbedColor.INFO,
this.description = "Do you have time on the following Days?" "Time Planning Feature",
this.footer { "Do you have time on the following Days?",
this.icon = Bot.bot.kordRef.getSelf().avatar?.cdnUrl?.toUrl() "Automated Message"
this.text = MessageUtil.getFooter() )
} )
}
} }
} }
delay(2000) delay(2000)
var then = ZonedDateTime.now(ZoneId.of("Europe/Berlin")).withHour(4).withMinute(0).withSecond(0) var then = ZonedDateTime.now(ZoneId.of("Europe/Berlin")).withHour(4).withMinute(0).withSecond(0)
repeat(7) { repeat(7) {
val eb = MessageUtil.getEmbedWithTable(
EmbedColor.INFO,
"",
"${then.dayOfWeek.name}, ${then.dayOfMonth}.${then.monthValue}.${then.year} /${it + 1}. weekday",
mapOf(
"Is available" to listOf(),
"May be available" to listOf(),
"Is not available" to listOf()
)
)
val msg = c.createMessage { val msg = c.createMessage {
this.embed { this.embeds.add(
this.color = eb.color MessageUtil.getEmbedWithTable(
this.title = eb.title EmbedColor.INFO,
this.description = eb.description "",
this.fields = eb.fields "${then.dayOfWeek.name}, ${then.dayOfMonth}.${then.monthValue}.${then.year} /${it + 1}. weekday",
this.footer { mapOf(
this.icon = Bot.bot.kordRef.getSelf().avatar?.cdnUrl?.toUrl() "Is available" to listOf(),
this.text = MessageUtil.getFooter() "May be available" to listOf(),
} "Is not available" to listOf()
} )
)
)
this.actionRow { this.actionRow {
this.components.addAll(EmbedUtil.getTimePlannerButtons().components) this.components.addAll(EmbedUtil.getTimePlannerButtons().components)

View file

@ -41,7 +41,7 @@ object StatusUpdater : ICronjob {
private var statusList = listOf<String>() private var statusList = listOf<String>()
private var index = 0 private var index = 0
// I h8 this cronjob. I'll recode this someday. // I h8 this job. I'll recode this someday.
override suspend fun jobFunction() { override suspend fun jobFunction() {
if (index >= statusList.size) { if (index >= statusList.size) {
index = 0 index = 0

View file

@ -18,7 +18,10 @@
package net.moonleay.lilJudd.util package net.moonleay.lilJudd.util
import dev.kord.core.behavior.UserBehavior 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.entity.Embed import dev.kord.core.entity.Embed
import dev.kord.rest.builder.message.EmbedBuilder import dev.kord.rest.builder.message.EmbedBuilder
import java.time.LocalDateTime import java.time.LocalDateTime
@ -27,9 +30,44 @@ import java.time.format.DateTimeFormatter
object MessageUtil { object MessageUtil {
private val dtf: DateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy @ HH:mm:ss") private val dtf: DateTimeFormatter = DateTimeFormatter.ofPattern("dd/MM/yyyy @ HH:mm:ss")
suspend fun getFooter(u: UserBehavior? = null): String { ///Send an embedded message as a reply
val now: LocalDateTime = LocalDateTime.now() suspend fun sendEmbedForPublicSlashCommand(
return ">" + dtf.format(now) + " - ${u?.asUser()?.username ?: "Automated Message"}" ctx: PublicSlashCommandContext<Arguments, ModalForm>,
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<Arguments, ModalForm>,
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
)
)
}
} }
///Get a cloned embedded message ///Get a cloned embedded message
@ -63,6 +101,20 @@ object MessageUtil {
return ebb return ebb
} }
fun getEmbedWithTableWithFooter(
color: EmbedColor,
title: String,
description: String,
values: Map<String, List<String>>?,
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( fun getEmbedWithTable(
color: EmbedColor, color: EmbedColor,
title: String, title: String,
@ -84,6 +136,7 @@ object MessageUtil {
return ebb return ebb
} }
///Get an embedded msg with title and description ///Get an embedded msg with title and description
fun getEmbedSmall( fun getEmbedSmall(
color: EmbedColor, color: EmbedColor,
@ -111,4 +164,17 @@ object MessageUtil {
return ebb 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
}
} }