A drug dealer was caught after police seized his phone during an armed robbery investigation and found incriminating text messages.
Matthew Robinson was spared jailed after a court heard how the messages revealed he had sold 11 wraps of cocaine at a party on behalf of his brother.
Leeds Crown Court heard Robinson was arrested in March this year by officers investigating an armed robbery offence.
Dave Mackay, prosecuting, said Robinson was not involved in the robbery but his brother was subsequently charged and is serving a prison sentence.
The 24-year-old’s mobile phone was examined and a text referring to drug supply was found dating back to November 24 last year.
Robinson, of Hunters Way, Whitkirk, Leeds, was then arrested on suspicion of drug supply and made a full admission to officers.
He said he had sold £440 worth of the drug on behalf of his brother on a single occasion.
Robinson pleaded guilty to possession to supplying cocaine.
Ian Cook, mitigating, said Robinson had been frank with officers about what he had done and pleaded guilty at an early stage. He added that Robinson was a skilled roofer and was well regarded by his employer and in his local community..
Describing the offence, Mr Cook said: “It was one day of absolute stupidity on his part.”
Robinson was given a two-year prison sentence, suspended for two years.
He was also ordered to do 250 hours unpaid work.
He was also made the subject of a six-month curfew order.
Judge Penelope Belcher said: “You are plainly a man who has a lot to give to society - then you go and commit this offence knowing that it was illegal.
“You knew exactly what you were doing.
“You are looking at two years in custody straight in the eye for supplying 11 friends with cocaine at a party. What utter, utter stupidity.
The judge added: “I have decided that I am going to step back from immediate custody, but you are a lucky young man.
“You have escaped custody by a whisker.”