N0m4n904
N0m4n904

Reputation: 149

Crosspost Discord Message using Discord4j

I have a DiscordBot which was written with Discord4j using Kotlin. I send EmbedMessages with it and I want to publish these messages automatically. Does anyone have a clue how to do this? I have an embedbuilder and send the message with the following function.

fun sendEmbedMessage(gateway: GatewayDiscordClient, embed: EmbedCreateSpec, channelId: String) {
    gateway.getChannelById(Snowflake.of(channelId))
        .ofType(GuildMessageChannel::class.java)
        .flatMap { channel -> channel.createMessage(embed) }
        .subscribe()
}

Thanks in advance!

Upvotes: 1

Views: 356

Answers (1)

Minn
Minn

Reputation: 6134

You can use publish:

fun sendEmbedMessage(gateway: GatewayDiscordClient, embed: EmbedCreateSpec, channelId: String) {
    gateway.getChannelById(Snowflake.of(channelId))
        .ofType(GuildMessageChannel::class.java)
        .flatMap { channel -> channel.createMessage(embed) }
        .flatMap { message -> message.publish() }
        .subscribe()
}

Upvotes: 2

Related Questions