Skip to content

Commit

Permalink
fix: dedupe notification sending mechanic + handle single chapters
Browse files Browse the repository at this point in the history
  • Loading branch information
j1nxie committed Jan 21, 2025
1 parent 48a542f commit dfe8b3b
Showing 1 changed file with 15 additions and 25 deletions.
40 changes: 15 additions & 25 deletions src/chapter_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,33 +134,23 @@ pub async fn chapter_tracker(http: &Http, data: &Data) -> Result<(), Error> {
return Ok(());
}

if chapter_list.len() > 10 {
let chunks = chapter_list.chunks(10);

for chunk in chunks {
data.manga_update_channel_id
.unwrap()
.send_message(
&http,
CreateMessage::default()
.content("New chapters are out!")
.embeds(chunk.to_vec()),
)
.await?;
}
let chunks = chapter_list.chunks(10);

return Ok(());
for chunk in chunks {
data.manga_update_channel_id
.unwrap()
.send_message(
&http,
CreateMessage::default()
.content(if chunk.len() > 1 {
"New chapters are out!"
} else {
"A new chapter is out!"
})
.embeds(chunk.to_vec()),
)
.await?;
}

data.manga_update_channel_id
.unwrap()
.send_message(
&http,
CreateMessage::default()
.content("New chapters are out!")
.embeds(chapter_list),
)
.await?;

Ok(())
}

0 comments on commit dfe8b3b

Please sign in to comment.