A 17-year-old boy used Facebook to threaten a mass stabbing in Sydney and say the Orlando nightclub shooting victims deserved to die, a court has heard.

The boy, who cannot be identified due to his age, was arrested at his home in The Oaks, in south-western Sydney, on Tuesday night after also allegedly threatening to kill police officers in social media posts.

He applied for bail at Parramatta Children’s Court today but it was formally refused.

Police allege he wrote posts on Facebook in which he threatened to carry out mass killings with a knife.

The court heard the boy also wrote on Facebook that the victims of the Orlando massacre were “people that all deserved it, every each one of them”.

He allegedly went on to write “thank you and God bless for the shootings”, before ending the post with a love-heart emoticon.

The court also heard the boy created an “attack map” on his computer and had obtained a knife before allegedly erasing his hard drives.

Magistrate says no evidence of ‘exceptional circumstances’

The boy’s lawyer argued his client should be released on bail because his “youth and immaturity” constituted exceptional circumstances.

But the Commonwealth prosecutor opposed bail, arguing that police viewed the boy as a serious risk to the community, or sections of the community.

The magistrate denied the boy bail, saying his defence solicitor had failed to present sufficient evidence that he met the threshold for release under exceptional circumstances.

“I am not saying [exceptional circumstances] don’t exist,” he said.

“I am simply saying there is no evidence of it today.”

The teenager appeared visibly distressed, and his mother ran from the courtroom in tears when the decision was handed down this evening.

The boy will now remain in custody at the Cobham Juvenile Detention Centre and will face court again in August.

Boy has ‘anxiety, depression and Aspergers’

Police said the boy was not believed to have been motivated by religious extremism or Islamic State ideology, nor had any known links to terrorist groups.

The boy’s father yesterday said his son had never been to high school and had “anxiety, depression and Aspergers”.

Meanwhile, Police Commissioner Andrew Scipione said there was no immediate threat to the community but said police officers should remain vigilant as they were “currently targets”.

Commissioner Scipione said yesterday that officers found a social media post which spoke about violence against police officers.

He said the post referred to killing a police officer.

But he said it was necessary to keep in mind that the youth had “special needs” and the courts would take that into account.