@@ -25,7 +25,7 @@ public final class SuggestionsUpDownVoter extends MessageReceiverAdapter {
2525 private static final Logger logger = LoggerFactory .getLogger (SuggestionsUpDownVoter .class );
2626 private static final Emoji FALLBACK_UP_VOTE = Emoji .fromUnicode ("👍" );
2727 private static final Emoji FALLBACK_DOWN_VOTE = Emoji .fromUnicode ("👎" );
28- private static final int THREAD_TITLE_MAX_LENGTH = 60 ; // Define the max length
28+ private static final int THREAD_TITLE_MAX_LENGTH = 60 ;
2929
3030 private final SuggestionsConfig config ;
3131
@@ -55,22 +55,20 @@ public void onMessageReceived(MessageReceivedEvent event) {
5555 }
5656
5757 private static void createThread (Message message ) {
58- String threadTitle = generateThreadTitle (message .getContentRaw (),
59- message .getAuthor ().getName () + "'s suggestion" );
58+ String threadTitle = generateThreadTitle (message );
6059 message .createThreadChannel (threadTitle ).queue ();
6160 }
6261
6362 /**
64- * Generates a thread title, enforcing a maximum length of 60 characters. If an initial title
65- * exceeds this limit, it's truncated at the last word boundary before or at the 60-character
66- * mark to prevent cutting words mid-sentence. If no space is found, it truncates at 60
67- * characters. Uses a fallback title if the primary title is empty.
63+ * Generates a title for the given message. The maximum length of the title is
64+ * {@value #THREAD_TITLE_MAX_LENGTH}.
6865 *
69- * @param primaryTitle The primary title to use.
70- * @param fallbackTitle The fallback title to use if the primary title is empty.
66+ * @param message The message for which to generate the title.
7167 * @return The generated and truncated thread title.
7268 */
73- private static String generateThreadTitle (String primaryTitle , String fallbackTitle ) {
69+ private static String generateThreadTitle (Message message ) {
70+ String primaryTitle = message .getContentRaw ();
71+ String fallbackTitle = message .getAuthor ().getName () + "'s suggestion" ;
7472 String title = primaryTitle .isEmpty () ? fallbackTitle : primaryTitle ;
7573
7674 if (title .length () < THREAD_TITLE_MAX_LENGTH ) {
0 commit comments