Here is how SpongeBob, The Mane 6 and the new chosen ones of the new elements of harmony got captured by Merlock and his gang in The Tale of The SquarePants Master Ship Builders.
The crew returns to Ponyville.
SpongeBob SquarePants: We got all the Elements! Let's go!
Princess Luna: Good luck!
Rainbow Dash: Thanks. Come on, What're we waiting for? We gotta get the Elements of Harmony to the Tree!
Patrick Star: Right!
Soon, they ran through the Everfree Forest and reached the Tree of Harmony.
Rarity: Almost there!
Twilight Sparkle: We got to the Tree of Harmony!
Patrick Star: And not a moment too soon!
SpongeBob SquarePants: AMBUSH!!!
Spiny: Hello there. Gotcha!
Gremlin Prescott: (takes the elements) I'll take these!
Gremlin Gus: Give them back, Prescott!
Gremlin Prescott: No can do, Gus! (threw some goo bombs and trapped them all)
Squidward Tentacles: Eww! This is disgusting!
Merlock: Now, It's your turn, Discord! (brings out the enchanted bottle and opens it)
Discord: Oh no! (gets sucked in) You can't do this to me! I'm a free Spirit!
Merlock: Not anymore! (gives the bottle to Dijon) Guard them and sure they'll never escape.
Dijon: Yes, Merlock! As you command!
Twilight Sparkle: (trying to use her magic to break free) It's no use. I can't break loose!
Rarity: And We're stuck together!
Sunset Shimmer: It's no use for Alicorns or Unicorns!
Trixie: How'll we ever break.
Captain Bonemeal: Now, Equestria will face the wrath of Merlock!
Captain Stubbs: You won't get away with this, Bonemeal!
Captain Bonemeal: We already did! Hope you blokes enjoy your last moment! (evil laugh)