Bug fixes

This commit is contained in:
Wieland Schöbl
2021-05-28 22:41:09 +02:00
parent 712ff091af
commit d3d7b234a7
5 changed files with 69 additions and 11 deletions

View File

@@ -2,6 +2,7 @@
<dictionary name="wulkanat">
<words>
<w>crosspost</w>
<w>guilded</w>
<w>hytale</w>
</words>
</dictionary>

37
.idea/workspace.xml generated
View File

@@ -4,13 +4,16 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="1aabf22b-2f57-46ac-9973-367d8668ffd3" name="Default Changelist" comment="Add Twitter integration&#10;Add Job Listening Integration&#10;Various Refactorings">
<list default="true" id="1aabf22b-2f57-46ac-9973-367d8668ffd3" name="Default Changelist" comment="Update .gitignore">
<change afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/webhook/WebhookCaller.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/dictionaries/wulkanat.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dictionaries/wulkanat.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/AdminCli.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/AdminCli.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/web/Parser.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/web/Parser.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/web/SiteWatcher.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/web/SiteWatcher.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/Channels.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/Channels.kt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/extensions/Message.kt" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/kotlin/de/wulkanat/extensions/Message.kt" afterDir="false" />
</list>
<list id="44283a45-f406-407f-bce2-a31bb9bfc0cc" name="Changes by Valentin" comment="Changes by Valentin">
<change beforePath="$PROJECT_DIR$/src/main/java/org/hmcore/WebhookCaller.java" beforeDir="false" />
</list>
<list id="44283a45-f406-407f-bce2-a31bb9bfc0cc" name="Changes by Valentin" comment="Changes by Valentin" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -45,9 +48,9 @@
<option name="RECENT_TEMPLATES">
<list>
<option value="Kotlin Class" />
<option value="Kotlin Object" />
<option value="Kotlin File" />
<option value="Class" />
<option value="Kotlin Object" />
</list>
</option>
</component>
@@ -219,7 +222,7 @@
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1597322033373</updated>
<workItem from="1622225780094" duration="7689000" />
<workItem from="1622225780094" duration="8575000" />
</task>
<task id="LOCAL-00001" summary="Add auto publish feature">
<created>1597437833375</created>
@@ -298,7 +301,21 @@
<option name="project" value="LOCAL" />
<updated>1622232613740</updated>
</task>
<option name="localTasksCounter" value="12" />
<task id="LOCAL-00012" summary="Add more extensive fake update capabilities">
<created>1622233686973</created>
<option name="number" value="00012" />
<option name="presentableId" value="LOCAL-00012" />
<option name="project" value="LOCAL" />
<updated>1622233686973</updated>
</task>
<task id="LOCAL-00013" summary="Update .gitignore">
<created>1622233754088</created>
<option name="number" value="00013" />
<option name="presentableId" value="LOCAL-00013" />
<option name="project" value="LOCAL" />
<updated>1622233754088</updated>
</task>
<option name="localTasksCounter" value="14" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@@ -327,7 +344,9 @@
<MESSAGE value="Add shards count configuration" />
<MESSAGE value="Add Twitter integration&#10;Add Job Listening Integration&#10;Various Refactorings" />
<MESSAGE value="Changes by Valentin" />
<option name="LAST_COMMIT_MESSAGE" value="Changes by Valentin" />
<MESSAGE value="Add more extensive fake update capabilities" />
<MESSAGE value="Update .gitignore" />
<option name="LAST_COMMIT_MESSAGE" value="Update .gitignore" />
</component>
<component name="XDebuggerManager">
<watches-manager>

View File

@@ -2,13 +2,13 @@
package de.wulkanat
import de.wulkanat.webhook.WebhookCaller
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import net.dv8tion.jda.api.EmbedBuilder
import net.dv8tion.jda.api.Permission
import net.dv8tion.jda.api.entities.Message
import org.hmcore.WebhookCaller
import java.awt.Color
object Channels {

View File

@@ -25,4 +25,4 @@ fun Message.crosspost(): MessageAction {
val CROSSPOST_MESSAGE: Route = Inaccessibles.getRoute(
Method.POST,
"channels/{channel_id}/messages/{message_id}/crosspost"
)
)

View File

@@ -0,0 +1,38 @@
package de.wulkanat.webhook
import de.wulkanat.WEBHOOKS
import net.dv8tion.jda.api.entities.Message
import org.hmcore.DiscordWebhook
import org.hmcore.DiscordWebhook.EmbedObject
import java.io.IOException
object WebhookCaller {
fun sendToGuildedNews(message: Message) {
val webhook = DiscordWebhook(WEBHOOKS.blogPostsWebhookUrl)
webhook.setContent(message.contentRaw)
webhook.setTts(false)
message.embeds.forEach { embed ->
webhook.addEmbed(EmbedObject().apply {
setAuthor(embed.author?.name, embed.author?.url, embed.author?.iconUrl)
color = embed.color
description = embed.description
setFooter(embed.footer?.text, embed.footer?.iconUrl)
title = embed.title
setImage(embed.image?.url)
setThumbnail(embed.thumbnail?.url)
url = embed.url
for (field in embed.fields) {
addField(field.name, field.value, field.isInline)
}
})
}
try {
webhook.execute()
} catch (e: IOException) {
e.printStackTrace()
}
}
}