Instead of all those $chr()s you can use

echo -a -- [bans] $+([,$3,] [,$4,] [,$duration($calc($ctime - $5)),])

echo -a -- [bans] [[ $+ $3 $+ ]] [[ $+ $4 $+ ]] [[ $+ $duration($calc($ctime - $5)) $+ ]]