The rapper, who shares two sons with Rihanna, faced up to 24 years in prison as prosecutors accused him of shooting at a former friend in 2021.