#TJ BOT | Trying to get data about thread

1 messages · Page 1 of 1 (latest)

uncut vessel
#

I am trying to get information about a thread in the questions thread. I want the title and first message. The title is easy enough. The first message for the thread is proving harder.

Here is a couple of my attempts:

String questionFirstMessage = threadChannel.retrieveParentMessage()
.complete().getContentDisplay();
String questionFirstMessage = threadChannel.getHistoryFromBeginning(1)     .complete().getRetrievedHistory().get(0).getContentDisplay();

But it seems that using complete() implicitly or explicitly isn't allowed. It appears that I have to use queue() and pass it along to another method, like this:

threadChannel.getHistoryFromBeginning(1).queue(messageHistory -> {
  methodToCompleteTask(messageHistory.getRetrievedHistory().get(0).getContentDisplay());

});

So my question is: Is there a nice way to get the String I want, like in the first two examples that doesn't use queue? Am I over complicating this?

edgy anvilBOT
#

<@&987246399047479336> please have a look, thanks.

edgy anvilBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

distant moat
indigo salmon
#

yeah please have an async call chain

#

using map and flatMap

#

foo.flatMap(x -> bar(x)).flatMap(...)...queue()

#

that said, afaik thread IDs are identical to the message id of the first message

#

so u might have luck by doing retrieveMessageById(threadId)

#

and then flatMap, since it's a action (=future)

uncut vessel
#

Alright I will give that a whirl - thanks!