mirror of
https://github.com/HMCore/Orbot.git
synced 2025-12-12 13:56:18 +00:00
Bug fixes
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -25,4 +25,4 @@ fun Message.crosspost(): MessageAction {
|
||||
val CROSSPOST_MESSAGE: Route = Inaccessibles.getRoute(
|
||||
Method.POST,
|
||||
"channels/{channel_id}/messages/{message_id}/crosspost"
|
||||
)
|
||||
)
|
||||
|
||||
38
src/main/kotlin/de/wulkanat/webhook/WebhookCaller.kt
Normal file
38
src/main/kotlin/de/wulkanat/webhook/WebhookCaller.kt
Normal 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()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user