Nobody said that you have to have either guns or melee. Just because guns are present doesn't mean hand-to-hand combat goes away. Bayonets are always an issue, as are sword and various other threats even later in the development of firearms technology. We would even still see people with very large, two-handed swords (greatswords) if it were to be around what our 14th-16th centuries were like. You would have cavalry, pikemen, halberds, knights, and, of course, muskets.
So firearms wouldn't negate magic or melee combat, but merely add a new threat, which I think we can all appreciate.