This is an excellent question, and is asked in many places such as here, here, here, here, and many other places. By far the best set of answers are found in the second link above, from Daf-yomi.com, with my rough summary below:
א. דבר ה' ליהושע היה בגילוי נבואה, והיא מדרגה עליונה של דבקות בקדושה. רק על גילוי נבואה נאמר שאין בו פחיתות ערך של דילטורין. אבל באופנים אחרים – כשם שה' מַגְבִּיהִי לָשָׁבֶת (תהלים קיג, ה) כך הוא גם מַשְׁפִּילִי לִרְאוֹת (שם ו).
ב. אמרו במסכת סנהדרין דף מג ע"ב:
"אמר לפניו: רבונו של עולם, מי חטא? אמר ליה: וכי דילטור אני? לך הפל גורלות. הלך והפיל גורלות, ונפל הגורל על עכן, אמר לו: יהושע, בגורל אתה בא עלי?! אתה ואלעזר הכהן שני גדולי הדור אתם, אם אני מפיל עליכם גורל - על אחד מכם הוא נופל. אמר לו: בבקשה ממך... מיד: ויען עכן את יהושע ויאמר אמנה אנכי חטאתי לה' אלהי ישראל וכזאת וכזאת עשיתי".
כפי שטען עכן, גם בגורל אין בכדי להוכיח ולהצביע על החוטא. תועלת הגורל היתה בכך שהוא שגרם לעכן להודות בעצמו על חטאו.
ג. דילטור הוא ההולך רכיל, כפירוש רש"י, ודרך לשון הרע להאמר בלחש ככתוב בקהלת י, יא: אִם יִשֹּׁךְ הַנָּחָשׁ בְּלוֹא לָחַשׁ וְאֵין יִתְרוֹן לְבַעַל הַלָּשׁוֹן. וכוונת ה' היתה שאין מן הראוי שיאשים יהושע את עכן בטענה כי מה' נלחש לו מאחורי גבו. ואילו עדות הגורל היא בפני עיני הכל.
Answer 1 - there is a difference between being a slanderer through Nevuah, a very holy method of communication between man and G-d. Only through this method would there be an issue of telling Lashon Hara, but not through a more natural method of communicating, such as a lottery.
Answer 2 - Indeed, Achan is correct in noting that a lottery does not conclusively prove anything. However, the purpose of the lottery was to put him in the spotlight and cause him to admit. (See here as well.) Indeed, Yehoshua even asks him to admit, which is emphasized by the very Gemara you are asking about.
Answer 3 - We see indications from many places that it is inappropriate to convict people from informers, who secretly tell Lashon Hara about people behind their backs. Therefore, here, Hashem desired that the lottery be done in front of the entire nation, to avoid being a private informer (this may work well with the language of the Gemara "וכי דילטור אני לך"?)