Replies: 2 comments
-
The best hack I have found so far...
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Your intuition to use Here's an example: MessageChannel channel = ... // get a channel from somewhere
List<String> messageContents = List.of("hello", "world", "foo", "bar"); // get a list of messages from somewhere. You can decide how this is computed from the original "large message"
Flux<Message> sentMessages = Flux.fromIterable(messageContents) // create a flux consisting of the above strings
.concatMap(channel::createMessage); // for each string, send a message. `concatMap` is used so the order is consistent
// make sure to subscribe to sentMessages somehow! (like returning it from an event handler) There are additional considerations like error handling (what should happen if one of the messages fails to send, for example), but this should be enough to get you started. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have absolutely no experience with Reactive Programming, Discord4J or programming Discord bots. I would like to send a number of messages at once, if the message we try to send is too large. I know that I can call .then() any number of times to send another message, but if the number of segmented messages is not known at compile time, that strategy does not work. I imagine this must be possible, but cannot seem to figure it out.
Any help would be greatly appreciated/
Beta Was this translation helpful? Give feedback.
All reactions