PROVIDENCE, R.I. (WPRI) — A suspended attorney accused of threatening to shoot a Rhode Island Supreme Court justice has accepted a plea deal.

Nicholas Gelfuso, 37, represented himself Wednesday morning in Providence Superior Court.

At his arraignment in January, detectives alleged Gelfuso sent a series of emails in which he threatened to blow up the Superior Courthouse in Providence and made threats against R.I. Supreme Court Justice William Robinson.

In court Wednesday, Gelfuso pleaded no contest to a charge of threats to a public official. In exchange, the state agreed to drop cyberstalking/cyber-harassment and disorderly conduct charges.

The judge ordered Gelfuso to undergo mental health counseling and have no contact with Justice Robinson.

In June 2017, the Supreme Court suspended Gelfuso from practicing law after the disciplinary counsel said he sent “rambling, incoherent” emails accusing a judge of being involved in “conspiratorial fringe religious sects.”

The court said it “could not in good conscience allow him to continue representing clients.”