diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index ed887fd..9abf481 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,16 +4,33 @@
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -47,10 +64,10 @@
@@ -83,6 +100,10 @@
+
+
+
+
@@ -108,14 +129,18 @@
+
+
+
+
-
+
@@ -127,6 +152,48 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+ true
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+ true
+ false
+
+
@@ -148,27 +215,6 @@
false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
- true
- false
-
-
@@ -190,12 +236,8 @@
false
-
-
-
-
-
+
@@ -203,11 +245,11 @@
+
+
-
-
@@ -222,7 +264,7 @@
1597322033373
-
+
1597437833375
@@ -315,7 +357,21 @@
1622233754088
-
+
+ 1622234469645
+
+
+
+ 1622234469645
+
+
+ 1622234477364
+
+
+
+ 1622234477364
+
+
@@ -343,10 +399,11 @@
-
-
+
+
+
diff --git a/build.gradle b/build.gradle
index b823dd8..ce842c0 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,7 +3,7 @@ plugins {
id 'org.jetbrains.kotlin.plugin.serialization' version '1.5.10'
}
-group 'de.wulkanat'
+group 'org.wulkanat'
version '2.0.0'
repositories {
@@ -23,6 +23,9 @@ dependencies {
implementation 'com.github.redouane59.twitter:twittered:1.20'
implementation group: 'org.quartz-scheduler', name: 'quartz', version: '2.3.2'
+
+ testImplementation 'io.mockk:mockk:1.11.0'
+ testImplementation 'org.jetbrains.kotlin:kotlin-test-junit:1.5.10'
}
compileKotlin {
@@ -34,7 +37,7 @@ compileTestKotlin {
jar {
manifest {
- attributes('Main-Class': 'de.wulkanat.MainKt')
+ attributes('Main-Class': 'org.wulkanat.MainKt')
}
}
@@ -45,7 +48,7 @@ task fatJar(type: Jar) {
})
with jar
manifest {
- attributes 'Main-Class': 'de.wulkanat.MainKt',
+ attributes 'Main-Class': 'org.wulkanat.MainKt',
'Implementation-Version': version
}
}
diff --git a/src/main/java/Inaccessibles.java b/src/main/java/Inaccessibles.java
deleted file mode 100644
index fa19041..0000000
--- a/src/main/java/Inaccessibles.java
+++ /dev/null
@@ -1,27 +0,0 @@
-import net.dv8tion.jda.internal.requests.Method;
-import net.dv8tion.jda.internal.requests.Route;
-
-import java.lang.reflect.Constructor;
-
-public class Inaccessibles {
- /**
- * This is private by default
- *
- * @param method look
- * @param route somewhere
- * @return else
- */
- public static Route getRoute(Method method, String route) {
- try {
- Constructor> constructor = Route.class.getDeclaredConstructor(Method.class, String.class);
- constructor.setAccessible(true);
- return (Route) constructor.newInstance(method, route);
- } catch (Exception e) {
- return null;
- }
- }
-
- public static String toUnsignedString(long num) {
- return Long.toUnsignedString(num);
- }
-}
diff --git a/src/main/java/org/hmcore/TwitterJob.java b/src/main/java/org/hmcore/TwitterJob.java
index 7187f7c..fba04d2 100644
--- a/src/main/java/org/hmcore/TwitterJob.java
+++ b/src/main/java/org/hmcore/TwitterJob.java
@@ -3,8 +3,6 @@ package org.hmcore;
import com.github.redouane59.twitter.TwitterClient;
import com.github.redouane59.twitter.dto.tweet.Tweet;
import com.github.redouane59.twitter.signature.TwitterCredentials;
-import de.wulkanat.Admin;
-import de.wulkanat.Channels;
import net.dv8tion.jda.api.MessageBuilder;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
diff --git a/src/main/kotlin/de/wulkanat/extensions/Message.kt b/src/main/kotlin/de/wulkanat/extensions/Message.kt
deleted file mode 100644
index f4fd895..0000000
--- a/src/main/kotlin/de/wulkanat/extensions/Message.kt
+++ /dev/null
@@ -1,28 +0,0 @@
-package de.wulkanat.extensions
-
-import Inaccessibles
-import net.dv8tion.jda.api.entities.Message
-import net.dv8tion.jda.api.entities.MessageChannel
-import net.dv8tion.jda.api.requests.restaction.MessageAction
-import net.dv8tion.jda.internal.requests.Method
-import net.dv8tion.jda.internal.requests.Route
-import net.dv8tion.jda.internal.requests.restaction.MessageActionImpl
-import net.dv8tion.jda.internal.utils.Checks
-
-fun MessageChannel.crosspostById(messageId: String): MessageAction {
- Checks.isSnowflake(messageId, "Message ID")
-
- val route = CROSSPOST_MESSAGE.compile(id, messageId)
- return MessageActionImpl(jda, route, this).append("This is not of your interest.")
-}
-
-fun Message.crosspost(): MessageAction {
- val messageId = Inaccessibles.toUnsignedString(idLong)
-
- return channel.crosspostById(messageId)
-}
-
-val CROSSPOST_MESSAGE: Route = Inaccessibles.getRoute(
- Method.POST,
- "channels/{channel_id}/messages/{message_id}/crosspost"
-)
diff --git a/src/main/kotlin/de/wulkanat/model/BlogPostPreview.kt b/src/main/kotlin/de/wulkanat/model/BlogPostPreview.kt
deleted file mode 100644
index fd11409..0000000
--- a/src/main/kotlin/de/wulkanat/model/BlogPostPreview.kt
+++ /dev/null
@@ -1,27 +0,0 @@
-package de.wulkanat.model
-
-import net.dv8tion.jda.api.EmbedBuilder
-import net.dv8tion.jda.api.entities.MessageEmbed
-import de.wulkanat.extensions.hex2Rgb
-import kotlinx.serialization.Serializable
-
-@Serializable
-data class BlogPostPreview(
- val title: String,
- val description: String,
- val date: String,
- val author: String,
- val imgUrl: String,
- val fullPostUrl: String
-) {
- fun toMessageEmbed(): MessageEmbed {
- return EmbedBuilder()
- .setTitle(this.title, this.fullPostUrl)
- .setDescription(this.description)
- .setAuthor(this.author)
- .setThumbnail(this.imgUrl)
- .setFooter(this.date, "https://www.hytale.com/static/images/logo-h.png")
- .setColor(hex2Rgb("#337fb0"))
- .build()
- }
-}
\ No newline at end of file
diff --git a/src/main/kotlin/de/wulkanat/Admin.kt b/src/main/kotlin/org/hmcore/Admin.kt
similarity index 95%
rename from src/main/kotlin/de/wulkanat/Admin.kt
rename to src/main/kotlin/org/hmcore/Admin.kt
index e0373c9..e4c8a30 100644
--- a/src/main/kotlin/de/wulkanat/Admin.kt
+++ b/src/main/kotlin/org/hmcore/Admin.kt
@@ -1,8 +1,8 @@
@file:JvmName("Admin")
-package de.wulkanat
+package org.hmcore
-import de.wulkanat.extensions.embed
+import org.hmcore.extensions.embed
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
import net.dv8tion.jda.api.entities.MessageEmbed
@@ -23,7 +23,7 @@ object Admin {
fun connectToUser() {
Main.jdas.find { jda ->
jda.retrieveUserById(userId).complete()?.also { admin = it } != null
- } ?: return kotlin.io.println("Connection to de.wulkanat.Admin failed!")
+ } ?: return kotlin.io.println("Connection to org.hmcore.Admin failed!")
kotlin.io.println("Connected to ${admin!!.name}. No further errors will be printed here.")
}
diff --git a/src/main/kotlin/de/wulkanat/AdminCli.kt b/src/main/kotlin/org/hmcore/AdminCli.kt
similarity index 96%
rename from src/main/kotlin/de/wulkanat/AdminCli.kt
rename to src/main/kotlin/org/hmcore/AdminCli.kt
index 610e576..5a3a0df 100644
--- a/src/main/kotlin/de/wulkanat/AdminCli.kt
+++ b/src/main/kotlin/org/hmcore/AdminCli.kt
@@ -1,11 +1,10 @@
-package de.wulkanat
+package org.hmcore
-import de.wulkanat.web.fakeUpdateBlogPost
-import de.wulkanat.web.fakeUpdateJobListings
+import org.hmcore.web.fakeUpdateBlogPost
+import org.hmcore.web.fakeUpdateJobListings
import net.dv8tion.jda.api.hooks.ListenerAdapter
import net.dv8tion.jda.api.EmbedBuilder
import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent
-import org.hmcore.TwitterJob
import java.awt.Color
import kotlin.system.exitProcess
diff --git a/src/main/kotlin/de/wulkanat/Channels.kt b/src/main/kotlin/org/hmcore/Channels.kt
similarity index 99%
rename from src/main/kotlin/de/wulkanat/Channels.kt
rename to src/main/kotlin/org/hmcore/Channels.kt
index 7a93c75..99946dc 100644
--- a/src/main/kotlin/de/wulkanat/Channels.kt
+++ b/src/main/kotlin/org/hmcore/Channels.kt
@@ -1,8 +1,8 @@
@file:JvmName("Channels")
-package de.wulkanat
+package org.hmcore
-import de.wulkanat.webhook.WebhookCaller
+import org.hmcore.webhook.WebhookCaller
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
diff --git a/src/main/kotlin/de/wulkanat/DataIO.kt b/src/main/kotlin/org/hmcore/DataIO.kt
similarity index 92%
rename from src/main/kotlin/de/wulkanat/DataIO.kt
rename to src/main/kotlin/org/hmcore/DataIO.kt
index 51300db..54d0005 100644
--- a/src/main/kotlin/de/wulkanat/DataIO.kt
+++ b/src/main/kotlin/org/hmcore/DataIO.kt
@@ -1,9 +1,7 @@
@file:JvmName("DataIO")
-package de.wulkanat
+package org.hmcore
-import de.wulkanat.extensions.ensureExists
-import de.wulkanat.model.BlogPostPreview
-import de.wulkanat.model.JobListingPreview
+import org.hmcore.extensions.ensureExists
import kotlinx.serialization.Required
import kotlinx.serialization.Serializable
import kotlinx.serialization.decodeFromString
diff --git a/src/main/kotlin/de/wulkanat/DiscordRpc.kt b/src/main/kotlin/org/hmcore/DiscordRpc.kt
similarity index 79%
rename from src/main/kotlin/de/wulkanat/DiscordRpc.kt
rename to src/main/kotlin/org/hmcore/DiscordRpc.kt
index 20351b5..4586b82 100644
--- a/src/main/kotlin/de/wulkanat/DiscordRpc.kt
+++ b/src/main/kotlin/org/hmcore/DiscordRpc.kt
@@ -1,7 +1,4 @@
-package de.wulkanat
-
-import net.dv8tion.jda.api.JDA
-import net.dv8tion.jda.api.entities.Activity
+package org.hmcore
object DiscordRpc {
diff --git a/src/main/kotlin/de/wulkanat/ErrorHandler.kt b/src/main/kotlin/org/hmcore/ErrorHandler.kt
similarity index 93%
rename from src/main/kotlin/de/wulkanat/ErrorHandler.kt
rename to src/main/kotlin/org/hmcore/ErrorHandler.kt
index 6663b6f..1f45460 100644
--- a/src/main/kotlin/de/wulkanat/ErrorHandler.kt
+++ b/src/main/kotlin/org/hmcore/ErrorHandler.kt
@@ -1,4 +1,4 @@
-package de.wulkanat
+package org.hmcore
import net.dv8tion.jda.api.events.ExceptionEvent
import net.dv8tion.jda.api.hooks.ListenerAdapter
diff --git a/src/main/kotlin/de/wulkanat/Main.kt b/src/main/kotlin/org/hmcore/Main.kt
similarity index 97%
rename from src/main/kotlin/de/wulkanat/Main.kt
rename to src/main/kotlin/org/hmcore/Main.kt
index 9cdf83c..6e62986 100644
--- a/src/main/kotlin/de/wulkanat/Main.kt
+++ b/src/main/kotlin/org/hmcore/Main.kt
@@ -1,6 +1,6 @@
-package de.wulkanat
+package org.hmcore
-import de.wulkanat.web.getNewBlogPosts
+import org.hmcore.web.getNewBlogPosts
import net.dv8tion.jda.api.JDA
import net.dv8tion.jda.api.JDABuilder
import net.dv8tion.jda.api.MessageBuilder
@@ -9,7 +9,6 @@ import net.dv8tion.jda.api.requests.GatewayIntent
import net.dv8tion.jda.api.utils.ChunkingFilter
import net.dv8tion.jda.api.utils.MemberCachePolicy
import net.dv8tion.jda.api.utils.cache.CacheFlag
-import org.hmcore.TwitterJob
import org.quartz.CronScheduleBuilder.cronSchedule
import org.quartz.JobBuilder.newJob
import org.quartz.JobDetail
diff --git a/src/main/kotlin/de/wulkanat/OwnerCli.kt b/src/main/kotlin/org/hmcore/OwnerCli.kt
similarity index 99%
rename from src/main/kotlin/de/wulkanat/OwnerCli.kt
rename to src/main/kotlin/org/hmcore/OwnerCli.kt
index 3c7cfec..b9793bd 100644
--- a/src/main/kotlin/de/wulkanat/OwnerCli.kt
+++ b/src/main/kotlin/org/hmcore/OwnerCli.kt
@@ -1,4 +1,4 @@
-package de.wulkanat
+package org.hmcore
import net.dv8tion.jda.api.EmbedBuilder
import net.dv8tion.jda.api.Permission
diff --git a/src/main/kotlin/de/wulkanat/extensions/Color.kt b/src/main/kotlin/org/hmcore/extensions/Color.kt
similarity index 89%
rename from src/main/kotlin/de/wulkanat/extensions/Color.kt
rename to src/main/kotlin/org/hmcore/extensions/Color.kt
index 00ed297..ce7b474 100644
--- a/src/main/kotlin/de/wulkanat/extensions/Color.kt
+++ b/src/main/kotlin/org/hmcore/extensions/Color.kt
@@ -1,4 +1,4 @@
-package de.wulkanat.extensions
+package org.hmcore.extensions
import java.awt.Color
diff --git a/src/main/kotlin/de/wulkanat/extensions/Embed.kt b/src/main/kotlin/org/hmcore/extensions/Embed.kt
similarity index 63%
rename from src/main/kotlin/de/wulkanat/extensions/Embed.kt
rename to src/main/kotlin/org/hmcore/extensions/Embed.kt
index 69a5ca4..6261865 100644
--- a/src/main/kotlin/de/wulkanat/extensions/Embed.kt
+++ b/src/main/kotlin/org/hmcore/extensions/Embed.kt
@@ -1,4 +1,4 @@
-package de.wulkanat.extensions
+package org.hmcore.extensions
import net.dv8tion.jda.api.EmbedBuilder
import java.awt.Color
@@ -23,6 +23,12 @@ class EmbedBuilderBuilder {
}
get() = Color.BLACK
+ var thumbnail: String?
+ set(value) {
+ _embed.setThumbnail(value)
+ }
+ get() = null
+
fun field(builder: FieldBuilderBuilder.() -> Unit) =
FieldBuilderBuilder().apply { builder() }.let {
_embed.addField(it.name, it.value, it.inline)
@@ -32,6 +38,16 @@ class EmbedBuilderBuilder {
AuthorBuilderBuilder().apply { builder() }.let {
_embed.setAuthor(it.name, it.url, it.icon)
}
+
+ fun title(builder: TitleBuilderBuilder.() -> Unit) =
+ TitleBuilderBuilder().apply { builder() }.let {
+ _embed.setTitle(it.title, it.url)
+ }
+
+ fun footer(builder: FooterBuilderBuilder.() -> Unit) =
+ FooterBuilderBuilder().apply { builder() }.let {
+ _embed.setFooter(it.value, it.iconUrl)
+ }
}
class FieldBuilderBuilder {
@@ -40,11 +56,21 @@ class FieldBuilderBuilder {
var inline = false
}
+class TitleBuilderBuilder {
+ var title: String? = null
+ var url: String? = null
+}
+
class AuthorBuilderBuilder {
var name: String? = null
var url: String? = null
var icon: String? = null
}
+class FooterBuilderBuilder {
+ var value: String? = null
+ var iconUrl: String? = null
+}
+
fun embed(builder: EmbedBuilderBuilder.() -> Unit) =
EmbedBuilderBuilder().apply { builder() }._embed.build()
\ No newline at end of file
diff --git a/src/main/kotlin/de/wulkanat/extensions/File.kt b/src/main/kotlin/org/hmcore/extensions/File.kt
similarity index 87%
rename from src/main/kotlin/de/wulkanat/extensions/File.kt
rename to src/main/kotlin/org/hmcore/extensions/File.kt
index 6ab8b3a..fb30a07 100644
--- a/src/main/kotlin/de/wulkanat/extensions/File.kt
+++ b/src/main/kotlin/org/hmcore/extensions/File.kt
@@ -1,4 +1,4 @@
-package de.wulkanat.extensions
+package org.hmcore.extensions
import java.io.File
diff --git a/src/main/kotlin/de/wulkanat/extensions/Jsoup.kt b/src/main/kotlin/org/hmcore/extensions/Jsoup.kt
similarity index 91%
rename from src/main/kotlin/de/wulkanat/extensions/Jsoup.kt
rename to src/main/kotlin/org/hmcore/extensions/Jsoup.kt
index 6a635e9..b384ae4 100644
--- a/src/main/kotlin/de/wulkanat/extensions/Jsoup.kt
+++ b/src/main/kotlin/org/hmcore/extensions/Jsoup.kt
@@ -1,4 +1,4 @@
-package de.wulkanat.extensions
+package org.hmcore.extensions
import org.jsoup.nodes.Element
import org.jsoup.select.Elements
diff --git a/src/main/kotlin/org/hmcore/model/BlogPostPreview.kt b/src/main/kotlin/org/hmcore/model/BlogPostPreview.kt
new file mode 100644
index 0000000..f9b437d
--- /dev/null
+++ b/src/main/kotlin/org/hmcore/model/BlogPostPreview.kt
@@ -0,0 +1,33 @@
+package org.hmcore.model
+
+import org.hmcore.extensions.hex2Rgb
+import kotlinx.serialization.Serializable
+import org.hmcore.extensions.embed
+
+@Serializable
+data class BlogPostPreview(
+ val title: String,
+ val description: String,
+ val date: String,
+ val author: String,
+ val imgUrl: String,
+ val fullPostUrl: String
+) {
+ fun toMessageEmbed() = embed {
+ title {
+ title = this@BlogPostPreview.title
+ url = fullPostUrl
+ }
+ description = this@BlogPostPreview.description
+ color = hex2Rgb("#337FB0")
+ thumbnail = imgUrl
+
+ author {
+ name = author
+ }
+ footer {
+ value = date
+ iconUrl = "https://www.hytale.com/static/images/logo-h.png"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/wulkanat/model/JobListingPreview.kt b/src/main/kotlin/org/hmcore/model/JobListingPreview.kt
similarity index 89%
rename from src/main/kotlin/de/wulkanat/model/JobListingPreview.kt
rename to src/main/kotlin/org/hmcore/model/JobListingPreview.kt
index ff3356c..fcc022b 100644
--- a/src/main/kotlin/de/wulkanat/model/JobListingPreview.kt
+++ b/src/main/kotlin/org/hmcore/model/JobListingPreview.kt
@@ -1,6 +1,6 @@
-package de.wulkanat.model
+package org.hmcore.model
-import de.wulkanat.extensions.hex2Rgb
+import org.hmcore.extensions.hex2Rgb
import kotlinx.serialization.Serializable
import net.dv8tion.jda.api.EmbedBuilder
import net.dv8tion.jda.api.entities.MessageEmbed
diff --git a/src/main/kotlin/de/wulkanat/web/Parser.kt b/src/main/kotlin/org/hmcore/web/Parser.kt
similarity index 85%
rename from src/main/kotlin/de/wulkanat/web/Parser.kt
rename to src/main/kotlin/org/hmcore/web/Parser.kt
index ccbc02b..5d0eda7 100644
--- a/src/main/kotlin/de/wulkanat/web/Parser.kt
+++ b/src/main/kotlin/org/hmcore/web/Parser.kt
@@ -1,11 +1,11 @@
-package de.wulkanat.web
+package org.hmcore.web
-import de.wulkanat.extensions.absUrl
-import de.wulkanat.extensions.get
-import de.wulkanat.extensions.imgSrc
-import de.wulkanat.extensions.text
-import de.wulkanat.model.BlogPostPreview
-import de.wulkanat.model.JobListingPreview
+import org.hmcore.extensions.absUrl
+import org.hmcore.extensions.get
+import org.hmcore.extensions.imgSrc
+import org.hmcore.extensions.text
+import org.hmcore.model.BlogPostPreview
+import org.hmcore.model.JobListingPreview
private const val BLOG_POST_STATE_FILE_NAME = "blog_state.json"
fun fakeUpdateBlogPost(amount: Int = 1) = removeFromSiteSave(BLOG_POST_STATE_FILE_NAME, amount)
diff --git a/src/main/kotlin/de/wulkanat/web/SiteWatcher.kt b/src/main/kotlin/org/hmcore/web/SiteWatcher.kt
similarity index 98%
rename from src/main/kotlin/de/wulkanat/web/SiteWatcher.kt
rename to src/main/kotlin/org/hmcore/web/SiteWatcher.kt
index 1584619..8e57c81 100644
--- a/src/main/kotlin/de/wulkanat/web/SiteWatcher.kt
+++ b/src/main/kotlin/org/hmcore/web/SiteWatcher.kt
@@ -1,4 +1,4 @@
-package de.wulkanat.web
+package org.hmcore.web
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
diff --git a/src/main/kotlin/de/wulkanat/webhook/WebhookCaller.kt b/src/main/kotlin/org/hmcore/webhook/WebhookCaller.kt
similarity index 95%
rename from src/main/kotlin/de/wulkanat/webhook/WebhookCaller.kt
rename to src/main/kotlin/org/hmcore/webhook/WebhookCaller.kt
index 1affa34..5faa7f0 100644
--- a/src/main/kotlin/de/wulkanat/webhook/WebhookCaller.kt
+++ b/src/main/kotlin/org/hmcore/webhook/WebhookCaller.kt
@@ -1,6 +1,6 @@
-package de.wulkanat.webhook
+package org.hmcore.webhook
-import de.wulkanat.WEBHOOKS
+import org.hmcore.WEBHOOKS
import net.dv8tion.jda.api.entities.Message
import org.hmcore.DiscordWebhook
import org.hmcore.DiscordWebhook.EmbedObject
diff --git a/src/test/kotlin/org/hmcore/extensions/ColorTest.kt b/src/test/kotlin/org/hmcore/extensions/ColorTest.kt
new file mode 100644
index 0000000..97505f8
--- /dev/null
+++ b/src/test/kotlin/org/hmcore/extensions/ColorTest.kt
@@ -0,0 +1,16 @@
+package org.hmcore.extensions
+
+import org.junit.Assert.assertEquals
+import org.junit.Test
+import java.awt.Color
+
+class ColorTest {
+ @Test
+ fun `color should parse from hex correctly`() {
+ assertEquals(hex2Rgb("#FFFFFF"), Color.WHITE)
+ assertEquals(hex2Rgb("#000000"), Color.BLACK)
+ assertEquals(hex2Rgb("#FF0000"), Color.RED)
+ assertEquals(hex2Rgb("#00FF00"), Color.GREEN)
+ assertEquals(hex2Rgb("#0000FF"), Color.BLUE)
+ }
+}
\ No newline at end of file
diff --git a/src/test/kotlin/org/hmcore/extensions/EmbedTest.kt b/src/test/kotlin/org/hmcore/extensions/EmbedTest.kt
new file mode 100644
index 0000000..5bfa0c8
--- /dev/null
+++ b/src/test/kotlin/org/hmcore/extensions/EmbedTest.kt
@@ -0,0 +1,90 @@
+package org.hmcore.extensions
+
+import java.awt.Color
+import kotlin.test.Test
+import kotlin.test.assertEquals
+import kotlin.test.assertNotNull
+
+class EmbedTest {
+ @Test
+ fun `Embed Title DSL should work`() {
+ val dslEmbed = embed {
+ title {
+ title = "Title"
+ url = "https://a.b.c"
+ }
+ }
+
+ assertEquals("Title", dslEmbed.title)
+ assertEquals("https://a.b.c", dslEmbed.url)
+ }
+
+ @Test
+ fun `Embed Thumbnail should work`() {
+ val dslEmbed = embed {
+ thumbnail = "https://a.b.c"
+ }
+
+ assertNotNull(dslEmbed.thumbnail)
+ assertEquals("https://a.b.c", dslEmbed.thumbnail!!.url)
+ }
+
+ @Test
+ fun `Embed Footer DSL should work`() {
+ val dslEmbed = embed {
+ footer {
+ value = "Value"
+ iconUrl = "https://a.b.c"
+ }
+ }
+
+ assertNotNull(dslEmbed.footer)
+ assertEquals("Value", dslEmbed.footer!!.text)
+ assertEquals("https://a.b.c", dslEmbed.footer!!.iconUrl)
+ }
+
+ @Test
+ fun `Embed DSL should produce same result as native`() {
+ val dslEmbed = embed {
+ title = "A Title"
+ description = "A Description"
+ color = Color.YELLOW
+
+ author {
+ name = "An author"
+ icon = "https://d.e.f"
+ url = "https://a.b.c"
+ }
+
+ field {
+ inline = true
+ name = "Field1"
+ value = "Body1"
+ }
+
+ field {
+ inline = false
+ name = "Field2"
+ value = "Body2"
+ }
+ }
+
+ assertEquals("A Title", dslEmbed.title)
+ assertEquals("A Description", dslEmbed.description)
+ assertEquals(Color.YELLOW, dslEmbed.color)
+
+ assertNotNull(dslEmbed.author)
+ assertEquals("An author", dslEmbed.author!!.name)
+ assertEquals("https://d.e.f", dslEmbed.author!!.iconUrl)
+ assertEquals("https://a.b.c", dslEmbed.author!!.url)
+
+ assertEquals(2, dslEmbed.fields.size)
+ assertEquals("Field1", dslEmbed.fields[0].name)
+ assertEquals("Body1", dslEmbed.fields[0].value)
+ assertEquals(true, dslEmbed.fields[0].isInline)
+
+ assertEquals("Field2", dslEmbed.fields[1].name)
+ assertEquals("Body2", dslEmbed.fields[1].value)
+ assertEquals(false, dslEmbed.fields[1].isInline)
+ }
+}
\ No newline at end of file