kageru
7ebafc9958
Added a rawconfig as an intermediate step when parsing the TOML. This will make nullability much more reliable and also gives me lots of options in the future. It also broke all tests because reading the config (not the raw config) now depends on the discord API. :tehe:
30 lines
838 B
Kotlin
30 lines
838 B
Kotlin
package moe.kageru.kagebot
|
|
|
|
import org.javacord.api.entity.message.MessageAuthor
|
|
import org.javacord.api.entity.message.embed.EmbedBuilder
|
|
import org.javacord.api.entity.user.User
|
|
|
|
object MessageUtil {
|
|
fun mention(user: MessageAuthor): String {
|
|
return "<@${user.id}>"
|
|
}
|
|
|
|
fun mention(user: User): String {
|
|
return "<@${user.id}>"
|
|
}
|
|
|
|
|
|
fun getEmbedBuilder(): EmbedBuilder {
|
|
val builder = EmbedBuilder()
|
|
Globals.server.icon.ifPresent { builder.setThumbnail(it) }
|
|
return builder.setColor(Globals.config.system.color).setTimestampToNow()
|
|
}
|
|
|
|
fun mapToEmbed(contents: Map<String, String>): EmbedBuilder {
|
|
val builder = getEmbedBuilder()
|
|
for ((heading, content) in contents) {
|
|
builder.addField(heading, content)
|
|
}
|
|
return builder
|
|
}
|
|
} |