David Benioff and D.B. Weiss go from Westeros to Paddy's Pub by writing Wednesday's episode, with "Sunny" star Rob McElhenney telling THR: "They are just super-brilliant guys."

It's Always Sunny in Philadelphia has always been dark, but this week it's getting an infusion of bleak straight from Westeros.

Wednesday's episode, "Flowers for Charlie," was written by Game of Thrones creators David Benioff and D.B. Weiss, who are longtime fans of the show and became friendly with Rob McElhenney (Mac). The pair pitched McElhenney the story of the episode in a bar, and he was impressed.

PHOTOS: 'Game of Thrones'' Most Gruesome Death

The result sees Charlie (Charlie Day) undergo an experiment to increase his intelligence, a la the classic 1966 novel Flowers for Algernon. While on the surface Thrones couldn't be more different than Sunny, McElhenney says he isn't surprised Benioff and Weiss were able to nail a comedy script.

"They are just super-brilliant guys and understand scene structure and story structure," McElhenney tells The Hollywood Reporter. "I think a common misconception about comedy -- especially a show like ours -- is that it's just all jokes and that it's easy to sit down and just write funny things. Ours is a story-driven and character-driven show. It takes a specific structure to execute that, and they have that in spades."

RELATED: 'It's Always Sunny' Cast Talks Near Cancellation, Cult Status and Deciding an Endgame

The episode also reunites Day with his Pacific Rim costar Burn Gorman, who plays one of the scientists conducting the experiment on Charlie. Day says Benioff and Weiss came in with a deep understanding of Sunny.

"It was very flattering how well they knew the show and how well they knew the characters and our structure." Day says. "It's as if they knew our secrets."

"It turns out it's not that hard to do our show," McElhenney jokes, with Day adding: "I guess we'll have to do a Game of Thrones, we'll see."

It's Always Sunny in Philadelphia airs Wednesdays at 10 p.m. on FXX.