diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/discord.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/discord.rs b/src/discord.rs index 4f946bc..32cbf16 100644 --- a/src/discord.rs +++ b/src/discord.rs @@ -12,6 +12,7 @@ use log::info; use super::categories::Categorizable; const MAX_HOURS: i64 = 5; +const MAX_MESSAGE_LENGTH: usize = 2000; struct ShardManagerContainer; @@ -44,12 +45,15 @@ impl Handler { if let Some(mut m) = messages.pop() { let new_text = insert_link(&m.content, &self.log, &self.link); - m.edit(ctx, |m| m.content(new_text))?; - } else { - let new_text = insert_link("", &self.log, &self.link); - ChannelId(self.channel_id).say(ctx, new_text)?; + if new_text.len() <= MAX_MESSAGE_LENGTH { + m.edit(ctx, |m| m.content(new_text))?; + return Ok(()); + } } + let new_text = insert_link("", &self.log, &self.link); + ChannelId(self.channel_id).say(ctx, new_text)?; + Ok(()) } } |