President Donald Trump spent a good portion of a day meant to comfort the victims of recent mass shootings on Twitter attacking his political opponents.

Trump took to Twitter to attack everyone from former Vice President Joe Biden to the Fox News anchor Shepard Smith.

The president turned a day about gun-violence victims into a day about him, in effect making himself the victim.

Visit Business Insider's homepage for more stories.

As President Donald Trump traveled to Dayton, Ohio, and El Paso, Texas, to visit with the victims of mass shootings, he spent much of the day as he would any other — tweeting attacks at his political opponents.

He went after a wide array of people on Wednesday, including former Vice President Joe Biden, Dayton Mayor Nan Whaley, Democratic Sen. Sherrod Brown of Ohio, and the Fox News anchor Shepard Smith.

Indeed, on a day meant to focus on the victims of tragedies that have left the nation visibly traumatized, Trump aired his grievances with people who've been critical of him. In this sense, he made himself the victim.

Trump attacked the former vice president, whom he called "Sleepy Joe Biden," after Biden decried the president for fanning "the flames of white supremacy in this nation."

Read more: Trump condemned 'white supremacy' after the El Paso shooting, but his administration has made it harder to fight

He slammed Whaley and Brown after they held a press conference and said they'd called on Trump to take actions on gun violence during their brief meeting with him as he visited the Ohio city. Trump misleadingly accused them of "misrepresenting" his visit to a hospital by presenting it in a negative light, though Whaley had actually said the victims and first responders were "grateful" the president came to Dayton.

Trump didn't provide much context on why he was attacking Smith, but it's likely because he's among the few on Fox News who's often critical of the president.

Whaley, who's just a few days into leading Dayton through a tragedy that's rocked the community to its core, expressed genuine confusion at Trump's tweet attack.

"Not sure what the President thinks @SenSherrodBrown and I misrepresented," Whaley tweeted. "As we said, the victims and first responders were comforted by his presence. Let's hope he's not one of these all talk, no action politicians and actually does something on gun control."

American presidents are asked to play many roles depending on the circumstances at hand — including that of comforter in chief in the wake of national tragedies.

Former President Bill Clinton assumed this role after the Oklahoma City bombing in 1995, reassuring the city that the country would rally behind it and do all it could to help it heal from an unspeakable act of violence. Clinton, in what would be one of his most notable speeches, said, "You have lost too much, but you have not lost everything. And you have certainly not lost America, for we will stand with you for as many tomorrows as it takes."

Former President George W. Bush did the same after the 9/11 terror attacks, visiting the emergency workers at ground zero in downtown Manhattan and letting them know that he can "hear" them, adding, "and the people who knocked these buildings down will hear all of us soon."

And former President Barack Obama singing "Amazing Grace" at the funeral of South Carolina state Sen. Clementa Pinckney, who was killed in a 2015 shooting at a historic African American church in Charleston, South Carolina, remains one of the defining moments of his tenure.

Read more: Obama faced relentless opposition to gun reform, even after a shooting that left 20 children dead

But Trump has struggled to play this role. In many ways, he seems to have rejected the notion that it's his job to bring people together. The president often operates as though his base are the only Americans who matter.

As Trump visited Dayton and El Paso on Wednesday, he was met with protesters. Local leaders urged him to stay away. Trump did not visit the district in Dayton where the mass shooting occurred, which Whaley said was a "good decision" because of how "divisive" he can be.

He struggled to unify people after the deadly neo-Nazi violence in Charlottesville, Virginia, as he equivocated about white nationalism. He insulted the people of Puerto Rico with his tepid response to a devastating hurricane that left thousands dead but has continued to insist they should show gratitude as he lashes out at local leaders. And now after two mass shootings that occurred within less than 24 hours of each other over the weekend, Trump is attempting to simultaneously comfort a traumatized nation and go after people on Twitter.