aboutsummaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/meme/history.rs28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/commands/meme/history.rs b/src/commands/meme/history.rs
index 9651ba1..68416e5 100644
--- a/src/commands/meme/history.rs
+++ b/src/commands/meme/history.rs
@@ -300,11 +300,31 @@ pub async fn memers(ctx: PoiseContext<'_>) -> anyhow::Result<()> {
anyhow::Ok(res)
})
.try_collect::<Vec<String>>()
- .await?
- .into_iter()
- .join("\n");
+ .await?;
- util::reply(ctx, s).await?;
+ let mut out = String::new();
+
+ for line in s {
+ if line.len() >= 2000 {
+ anyhow::bail!("singular line too long");
+ }
+
+ if out.len() + line.len() >= 2000 {
+ let result = out.trim_end_matches('\n');
+ util::reply(ctx, &result).await?;
+ out.clear();
+ }
+
+ out.push_str(&line);
+ out.push('\n');
+ }
+
+ if !out.is_empty() {
+ let result = out.trim_end_matches('\n');
+ util::reply(ctx, result).await?;
+ } else {
+ util::reply(ctx, "no memers :(").await?;
+ }
Ok(())
}