Skip to content

Commit

Permalink
No need to use webhooks, just send as the bot
Browse files Browse the repository at this point in the history
  • Loading branch information
MrPowerGamerBR committed Oct 15, 2024
1 parent 7dcf79c commit d21639f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ data class GalleryOfDreamsConfig(
) {
@Serializable
data class DiscordConfig(
val token: String
)
val token: String,
val channels: DiscordChannelsConfig
) {
@Serializable
data class DiscordChannelsConfig(
val galleryLogId: Long
)
}

@Serializable
data class EtherealGambiConfig(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import club.minnced.discord.webhook.send.WebhookMessageBuilder
import dev.minn.jda.ktx.coroutines.await
import dev.minn.jda.ktx.generics.getChannel
import dev.minn.jda.ktx.messages.InlineMessage
import dev.minn.jda.ktx.messages.MessageCreate
import dev.minn.jda.ktx.messages.MessageEdit
import io.ktor.client.request.*
import io.ktor.client.statement.*
Expand Down Expand Up @@ -255,7 +256,6 @@ class GalleryOfDreamsCommand(val loritta: GalleryOfDreamsBackend) : SlashCommand
fanArtArtist
}


if (fanArtArtist == null) {
it.reply(true) {
styled(
Expand Down Expand Up @@ -321,19 +321,17 @@ class GalleryOfDreamsCommand(val loritta: GalleryOfDreamsBackend) : SlashCommand
}

GlobalScope.launch {
if (matchedFanArtArtist != null) {
loritta.webhookClient?.send(
WebhookMessageBuilder()
.setContent("<:gabriela_brush:727259143903248486> **Fan Art adicionada!** (<@${artistId}>) <a:lori_lick:957368372025262120> $newFanArtUrl")
.build()
)
} else {
loritta.webhookClient?.send(
WebhookMessageBuilder()
.setContent("<:gabriela_brush:727259143903248486> **Artista e Fan Art adicionadas!** (<@${artistId}>) <a:lori_lick:957368372025262120> $newFanArtUrl")
.build()
)
}
val galleryLogChannel = user.jda.getTextChannelById(loritta.config.discord.channels.galleryLogId)

galleryLogChannel?.sendMessage(
MessageCreate {
if (matchedFanArtArtist != null) {
content = "<:gabriela_brush:727259143903248486> **Fan Art adicionada!** (<@${artistId}>) <a:lori_lick:957368372025262120> $newFanArtUrl"
} else {
content = "<:gabriela_brush:727259143903248486> **Artista e Fan Art adicionadas!** (<@${artistId}>) <a:lori_lick:957368372025262120> $newFanArtUrl"
}
}
)?.await()
}
}
UploadFileResponse.FileAlreadyExists -> {
Expand Down

0 comments on commit d21639f

Please sign in to comment.