

NamiBot - Discord Bot
Associated with

Discord is a platform where people can connect with friends virtually through text and voice channels, watch movies together via screensharing, and more. It was already popular in 2019, but after Covid-19, it became the leading platform for online social interaction. As more people created their own servers and spent more time connecting virtually, I was inspired to develop a bot that could add fun and interactive features.
Discord allowed developers to create bots capable of performing virtually any task. Its API was extensive, with 12 versions available by early 2019. Using Node.js and integrating with Discord.js, I launched my first-ever Discord bot. In January 2019, NamiBot went live in the virtual world.
At first, I used Glitch, a free hosting service popular among Discord bot developers. On the free plan, the bot would go offline if unused for three hours and could only be restarted manually. This became frustrating, as I frequently received messages from users saying the bot was offline. So, I decided to rent a server for $24 per month to ensure better performance and keep the bot online 24/7.

My initial vision was simple, focusing on basic commands like kick, ban, mute, and role management, and it was well-received. At its peak, the bot was used in over 100 servers. I also developed a website for the bot, providing installation instructions and a guide for using the commands.

However, a challenge arose when the Discord team introduced a rule requiring bots with over 100 servers to be verified. Since my bot was already in over 100 servers, it could no longer join new ones.
First Discord Verified Bot in Mongolia
After months of completing documentation and going through the verification process, my bot finally became a Discord Verified Bot, earning the official badge. It also became the first Mongolian bot to achieve this milestone.
My next goal was to enable music streaming through the bot, allowing users to play their favorite songs with a single command: !play [music name]. At the time, I had no idea how to implement this feature, but I began researching online, reading countless articles about streaming protocols, audio encoding, and streaming without packet loss. The experience was incredibly challenging, yet rewarding, and taught me a great deal as a teenager passionate about coding.
I finally found a solution. When a user requests a song by name, I use GCP's YouTube API v3 to search for the song and retrieve data such as the full URL, title, artist, and thumbnail. This information enhances the user interface by displaying song details. To stream the song to the user’s Discord voice channel, the bot first joins the channel, then downloads the audio buffer from YouTube using the ytdl-core package. I convert the buffer to Opus format to optimize playback and prevent packet loss, and finally, use Discord’s streaming protocol to deliver the audio to the voice channel. This approach allows the bot to stream a song from YouTube using only the song name.

Retrieving data from YouTube using its API was challenging due to a daily limit of 100 searches per API key. To overcome this, I created 10 API keys and programmed the bot to switch to a new key whenever one reached its quota. This approach allowed me to handle up to 1,000 song requests per day.
Then I encountered a resource issue. When 30 users played songs simultaneously, the bot consumed nearly 13GB of RAM, which was very costly. My server had only 16GB of RAM, barely enough to handle 30 streams at once, yet I was offering the bot to users for free.
The Biggest Feature
Being just a music bot wasn’t unique, since many similar bots already existed. I needed new ideas to make it more engaging, and after some time, I came up with a custom currency system that allowed users to collect and spend currency by exchanging it for rewards. I named it NamiCoin.

Users could earn 100 free NamiCoin daily, roll dice to double their coins, or receive daily rewards from farms and other activities. They could spend their coins in the Nami Shop on items like profile badges, clothes, avatars, farm animals, and more. Farm animals also generated daily coins, for example, cows cost 100,000 coins and returned 1,000 coins per day, while chickens cost 10,000 coins and returned 100 coins per day. This system encouraged users to earn, invest, and spend their NamiCoin in ways that made the bot more fun and interactive.


After implementing this feature, users became increasingly engaged. The system included a leaderboard that ranked users based on their wealth, with more coins and items placing them higher. This sparked competition among users, transforming NamiBot into a more competitive platform rather than just a regular music bot. As a result, the bot grew to nearly 20,000 users, which was a remarkable achievement.

Unfortunately, due to limited resources, NamiBot was forced to shut down. The bot required significant resources, with monthly costs exceeding $500. Despite this, the project gave me invaluable experience in Node.js, managing complex requests, integrating the Discord API, and working with streaming protocols. I am very proud of what I was able to achieve and how far the bot reached at its peak.