Skip to content

Commit c91e82e

Browse files
committed
refactoring
* replacing Function type with Supplier for sendEmbedWithoutMention * changing variable for more clarity on fetched members
1 parent ec44733 commit c91e82e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

application/src/main/java/org/togetherjava/tjbot/features/help/HelpThreadAutoArchiver.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.Optional;
2424
import java.util.concurrent.TimeUnit;
2525
import java.util.function.Function;
26+
import java.util.function.Supplier;
2627

2728
/**
2829
* Routine, which periodically checks all help threads and archives them if there has not been any
@@ -129,21 +130,21 @@ private void handleArchiveFlow(ThreadChannel threadChannel, MessageEmbed embed)
129130
Function<Result<Member>, RestAction<Message>> sendEmbedWithMention =
130131
member -> threadChannel.sendMessage(member.get().getAsMention()).addEmbeds(embed);
131132

132-
Function<Result<Member>, RestAction<Message>> sendEmbedWithoutMention =
133-
member -> threadChannel.sendMessageEmbeds(embed);
133+
Supplier<RestAction<Message>> sendEmbedWithoutMention =
134+
() -> threadChannel.sendMessageEmbeds(embed);
134135

135136
threadChannel.getGuild()
136137
.retrieveMemberById(threadChannel.getOwnerIdLong())
137138
.mapToResult()
138-
.flatMap(member -> {
139-
if (member.isSuccess()) {
140-
return sendEmbedWithMention.apply(member);
139+
.flatMap(foundMember -> {
140+
if (foundMember.isSuccess()) {
141+
return sendEmbedWithMention.apply(foundMember);
141142
}
142143
LOGGER.info(
143144
"Owner of thread with id: {} left the server, sending embed without mention",
144-
threadChannel.getId(), member.getFailure());
145+
threadChannel.getId(), foundMember.getFailure());
145146

146-
return sendEmbedWithoutMention.apply(member);
147+
return sendEmbedWithoutMention.get();
147148
})
148149
.mapToResult()
149150
.flatMap(sentEmbed -> {

0 commit comments

Comments
 (0)