Correct me if I'm wrong: You have a plugin and don't own the source code of it. With two commands registered, meant to give user a specific weapon, you want those commands merged into one simple command where depending on player's team, you call one of those commands.
Also when you say randomly do you want the first player who writes buygun in console has the opportunity to get the weapon on his team?, or just pickup a random player at the end of freezetime and give 2 players from both teams custom weapons.