DEV Community

Cover image for Engineering Mikira: The Award-Winning AI Study & Music Bot for Discord
Ahmad Akmal Abdullah
Ahmad Akmal Abdullah

Posted on

Engineering Mikira: The Award-Winning AI Study & Music Bot for Discord

If you manage a Discord community for developers or students, you already know the infrastructure pain: you need one bot for music, another for moderation, and a third for studying. Half the time, the music bot crashes due to YouTube API limits, and the study bot is just a glorified text dumper.

I wanted to fix this. I didn't want just another generic bot; I wanted a unified, production-grade tool that handled complex audio pipelines and gamified programming education without ever forcing the user to leave the platform.

Enter Mikira—a multi-purpose Discord bot built on a modern asynchronous Python architecture.

It hasn't just solved the problem for local servers; it recently secured 6 international awards (4 Gold, 2 Silver) and has been officially registered under the Intellectual Property Corporation of Malaysia (MyIPO) as an AI Study Companion (Credential ID: CRLY2026E03369)[cite: 1].

Here is a fluff-free breakdown of how I architected Mikira, the tech stack, and the engineering methodology behind it.

The Architecture & Tech Stack

Mikira is written in Python 3.10+ and relies heavily on asynchronous event loops.

  • Framework: py-cord (for modern slash commands, voice, and interactive UI views).
  • Audio Pipeline: yt-dlp, spotipy, and system-level FFmpeg.
  • Concurrency: Python's native asyncio and concurrent.futures.
  • Data Persistence: JSON-backed per-guild settings.

1. Cog-Based Modular Design

To make the codebase scalable, I split the domains (Music, General, Study) into independent Discord Cogs[cite: 1]. This isolates the logic. If a music stream fails, it doesn't take down the quiz system.

2. Per-Guild State Isolation

One of the biggest issues with multi-server bots is state bleeding. Mikira uses global dictionaries (guild_to_audiocontroller and guild_to_settings) to ensure absolute isolation[cite: 1]. Each server gets its own playback queue, volume settings, and auto-timeout timers[cite: 1]. What happens in Server A never impacts Server B.

Engineering the Audio Pipeline

Building a music bot that doesn't break constantly requires aggressive fallback logic.

When a user fires /play:

  1. URL Identification: The bot detects if the link is YouTube, Spotify, SoundCloud, Bandcamp, or a direct media file[cite: 1]. Spotify tracks are automatically reverse-searched into YouTube queries via spotipy[cite: 1].
  2. Lazy Stream Resolution: To prevent massive latency when loading large playlists, songs are queued as metadata "shells" in an O(1) collections.deque[cite: 1]. The actual audio stream is only hydrated right before playback[cite: 1].
  3. Concurrent Preloading: While a song is playing, Mikira uses asyncio.ensure_future to preload upcoming tracks in the background, minimizing the gap between songs[cite: 1].
  4. Cookie Auth & Fallbacks: To bypass age-restricted or region-locked content, yt-dlp hooks into a Netscape cookie file[cite: 1]. If the primary extraction format fails, it gracefully falls back to a secondary format[cite: 1]. If that fails, it skips the track entirely rather than crashing the bot[cite: 1].

The Interactive Study Hub

The real utility of Mikira is the /study command. Instead of dumping PDFs into a chat, I engineered a fully interactive, button-driven UI using Discord's Views[cite: 1].

  • The Curriculum: It covers Python, JavaScript, Java, and C++ across 4 core CS chapters (Variables, Control Flow, Functions, OOP)[cite: 1].
  • Active Recall Quizzes: Users can take multiple-choice quizzes where both the questions and answers are randomized on every attempt to prevent position memorization[cite: 1].
  • Live Scoring & UI: The bot provides instant visual feedback—correct answers turn green, wrong answers turn red[cite: 1]. It tracks the score dynamically and outputs a performance tier (e.g., 90%+ is "Outstanding") with a visual progress bar (🟩⬜)[cite: 1].

Validation & Impact

Because of its resilient architecture and dual-purpose utility, Mikira was recognized at international innovation exhibitions, taking home 4 Gold and 2 Silver awards[cite: 1]. Protecting the source code and brand was crucial, leading to its official MyIPO registration[cite: 1].

The bot proves that Discord doesn't just have to be a chat app. With the right async architecture and interactive components, you can turn it into a gamified Learning Management System (LMS) and a resilient media player simultaneously.


I’m Ahmad Akmal (RuumiDev), a software developer specializing in interface design, systems architecture, and practical AI. If you prefer structured, practical engineering, let's connect:

Top comments (0)