Skip to main content

Command Palette

Search for a command to run...

Building a Johan Liebert Discord Bot with Gemini AI

Updated
3 min read

Introduction

As a fan of Monster and the character Johan Liebert, I wanted to create something unique—a Discord bot that responds with the calm, intelligent, and unsettling personality of Johan himself.

Instead of creating a standard chatbot, I decided to combine Discord.js with Google's Gemini API to build an AI-powered character bot.In this article, I'll walk through the project, the tech stack, challenges I faced, and what I learned along the way.

What is Johan Liebert?

Johan Liebert is the main antagonist of the anime and manga Monster. He is known for his intelligence, psychological manipulation, and mysterious personality.The goal of this project was not to recreate Johan perfectly, but to capture some of his speaking style and presence inside a Discord server.

Project Overview

The bot:

  • Listens to messages in Discord

  • Sends user prompts to Gemini AI

  • Generates responses inspired by Johan's personality

  • Returns responses directly inside Discord channels

Tech Stack:

  • Node.js

  • Discord.js

  • Google Gemini API

  • dotenv

Setting Up the Project

First, I created a Discord bot application and obtained a bot token.

Then I initialized a Node.js project:

npm init -y npm install discord.js dotenv @google/genai

Environment variables were stored in a .env file:

Connecting Discord.js

The bot uses Discord.js to connect to Discord and listen for incoming messages.

const { Client, GatewayIntentBits } = require("discord.js");

Once connected, the bot waits for messages and processes user input.

Integrating Gemini AI

The most interesting part was connecting Gemini.

Instead of manually writing hundreds of responses, I used Gemini to generate contextual replies.

This allowed the bot to:

  • Handle different conversations

  • Generate unique responses

  • Stay in character

Challenges I Faced

1. API Configuration Issues

Initially, I had trouble getting Gemini API requests working correctly.

I had to verify:

  • API keys

  • Environment variables

  • Request formats

2. Prompt Engineering

Making the bot sound like Johan was harder than expected. Generic prompts produced generic responses. I improved results by providing stronger personality instructions and behavioral constraints.

3. Discord Message Handling

Managing message events and avoiding unwanted bot responses required careful filtering.

What I Learned

This project taught me:

  • How Discord bots work internally

  • API integration in Node.js

  • Environment variable management

  • Prompt engineering basics

  • Debugging third-party services

Most importantly, I learned that building projects teaches far more than watching tutorials.

Future Improvements

Planned features include:

  • Memory system for conversations

  • Slash commands

  • Personality modes

  • Logging and analytics

  • Docker deployment

  • Hosting on a cloud server

Conclusion

Building the Johan Liebert Discord Bot was one of my most enjoyable projects so far.

It combined anime, AI, backend development, and Discord automation into a single project.

If you're learning backend development, I highly recommend building something based on your own interests. The motivation to keep improving the project becomes much stronger when you're genuinely excited about the idea.

Thanks for reading!

28 views
H
Himanshu7d ago

Great read! Looking forward to seeing more projects and blogs from you.

S

Thanks a lot! I'm really glad you liked it. , will post more such blogs regarding new project

A

Awesome project! Turning Johan Liebert into an AI-powered Discord bot is both creative and technically impressive. Great work

S

Thank you! I'm glad you enjoyed it. Building the bot was a fun experience, and I learned a lot along the way. More projects and posts coming soon!