Merge pull request #3 from dsec-hub/new_thread_title

updated gitignore, updated thread title to be leetcode titles
This commit is contained in:
RythonDev 2026-08-10 00:44:47 +10:00 committed by GitHub
commit b83ba5428d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 3 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
/target /target
.env .env
.env.*

View file

@ -62,8 +62,30 @@ async fn create_leetcode_thread(
let current_channel_id = &new_message.channel_id; let current_channel_id = &new_message.channel_id;
if leetcode_channel_id.eq(current_channel_id) { if leetcode_channel_id.eq(current_channel_id) {
let new_thread = serenity::CreateThread::new("🧠 DSEC LeetCode Challenge Answers"); fn create_title_from_message(message: impl Into<String>) -> String {
current_channel_id.create_thread_from_message(ctx, new_message.id, new_thread).await?; let message_string: String = message.into();
let title = message_string
.lines()
.next()
.map(|line| {
let start = line
.char_indices()
.nth(2)
.map(|(i, _)| i)
.unwrap_or(line.len());
&line[start..]
})
.unwrap_or("")
.to_string();
title
}
let new_thread =
serenity::CreateThread::new(create_title_from_message(&new_message.content));
current_channel_id
.create_thread_from_message(ctx, new_message.id, new_thread)
.await?;
}; };
Ok(()) Ok(())