The identical phrase "with drawn sword in his hand" “וְחַרְבּ֤וֹ שְׁלוּפָה֙ בְּיָד֔וֹ” is used on three occasions in the 24 books of Torah. How this relates each occurrence is unknown, but several hints in the adjacent texts color each instance. The common theme relates an angel that was dispatched to draw its sword in response to each event.
In Numbers 22:21 the verb used (וַתֵּ֤ט), veered Bilam's donkey off its path. In Joshua 5:13 the verb used ( וַיֵּ֨לֶךְ), inspired Joshua to approach the angel. In 1 Chronicles 21:16 the verb used (נְטוּיָ֖ה - source in Bilam's verb) directed the angel against Jerusalem, a potentially devastating outcome for residents of the ancient city.
In context; Bilam was commanded not to curse the Jewish people, but to speak only words placed in his mouth. The angel first spoke through the donkey to its owner Bilam before it addressed him directly. Joshua's angelic encounter carried instruction to destroy the walled city of Jericho. But, David fell into a state of repentance, never interacted directly with the angel and received its instruction to build an altar through the prophet Gad.
Bilam, the greatest shaman was hired to curse, but was redirected to bless Israel and hoped his fate would be like theirs; Joshua, the first to lead the Jewish people into their land was inspired to destroy Jericho, which would only be rebuilt after the final messianic revelation; David, Israel's king was directed, through the prophet to build an altar that tradition suggests became the site of their future temple.
The verb directing Bilam's and David's encounter, compared to Joshua suggests something is to be learned from the differential grammar in context of each use. This brings us to the mission of each angel; Bilam's angel appeared to the donkey, Joshua's exhibited holy affinity, David's elicited fear.
Its troubling that Bilam and David's encounters are associated, let alone that both result in building and offering personal sacrifice on altars. Despite Bilam's commitment not to curse Israel, he built seven altars to misdirect and justify his mercenary pursuit. David was instructed to build and sacrifice on one altar to effect his atonement. But, he misdirected his altar to engage the fractured tribes, who were fearful of plague to regain their endorsement. Neither Bilam or David's instance rose to the qualitative distinction of the verb or context used for Joshua.
Commentators accept David's quick action because it temporarily unified the nation and his son constructed the first permanent temple. But one generation later, mercenary pursuit by his treasurer, son and grandson shattered the nations fragile unity. As a result the tribes of Israel, that Bilam was tempted to curse would not be fully reunified until Jericho will be rebuilt.