Skip to content

Commit 5e78ce3

Browse files
committed
Don't truncate discord_sender in the middle of a char boundary
1 parent 6226cb8 commit 5e78ce3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/pterodactyl/smp_commands.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,11 @@ async fn broadcast_message(
293293
discord_sender += &format!(" {username}");
294294
}
295295
if discord_sender.len() > 32 {
296-
discord_sender.truncate(29);
296+
let mut new_len = 29;
297+
while !discord_sender.is_char_boundary(new_len) {
298+
new_len -= 1;
299+
}
300+
discord_sender.truncate(new_len);
297301
discord_sender += "...";
298302
}
299303
try_join_all(chat_bridge.discord_channels.iter().map(|channel| {

0 commit comments

Comments
 (0)