Skip to content

BabiDoo/gen-ai-discord-bot

Repository files navigation

🐉 gen-ai-discord-bot

Node.js Discord.js OpenAI Last Commit

An easy and customizable template to build Discord bots powered by LLM (Large Language Models). With this project, you can run personalized slash commands and easily extend the bot’s behavior for your server.


  • Connects to LLM APIs (e.g., OpenAI).
  • Ready-to-use slash command structure.
  • Personality and behavior fully customizable.
  • Written in JavaScript (Node.js).
  • Simple, extendable, and beginner-friendly.

📂 Project Structure

gen-ai-discord-bot/
├── .gitignore           
├── README.md            
├── deploy-commands.js   
├── index.js             
├── package.json         
├── package-lock.json    
└── viserion.jpg 

Requirements


🔑 Getting the Correct Discord Keys

To run the bot, you’ll need three important values from the Discord Developer Portal:

  1. Create an Application

  2. Create the Bot User

    • Inside your new application, go to the Bot tab.

    • Click Add Bot → confirm.

    • Here you’ll find the Bot Token → copy it and use it as DISCORD_TOKEN in your .env.

      ⚠️ Keep this token secret! If leaked, anyone can control your bot.

  3. Get the Client ID

    • Go to the OAuth2 → General tab.
    • Copy the Application ID → this is your CLIENT_ID.
  4. Get the Guild (Server) ID

    • In Discord, go to User Settings → Advanced and enable Developer Mode.
    • Right-click your server name → Copy Server ID → this is your GUILD_ID.
  5. Invite the Bot to Your Server

    • Go to OAuth2 → URL Generator.
    • Under Scopes, check bot and applications.commands.
    • Under Bot Permissions, select the permissions your bot needs (at least Send Messages and Use Slash Commands).
    • Copy the generated URL, paste it into your browser, and invite the bot to your server.

⚙️ Installation & Setup

  1. Clone this repository:
git clone https://github.com/BabiDoo/gen-ia-discord-bot.git
cd gen-ia-discord-bot
  1. Install the dependencies:
npm install
  1. Create a .env file at the project root and add your credentials:
DISCORD_TOKEN=your_discord_bot_token
CLIENT_ID=your_discord_client_id
GUILD_ID=your_discord_guild_id
OPENAI_API_KEY=your_openai_api_key
  1. Deploy slash commands to your Discord server:
node deploy-commands.js
  1. Start the bot:
node index.js

🎮 Example Usage

In your Discord server, type:

/fact

And the bot will reply with a random Game of Thrones fact (or whatever you configure).


🤝 Contributing

Contributions are welcome! To contribute:

  1. Fork this repository
  2. Create a new branch: git checkout -b feature-name
  3. Commit your changes: git commit -m 'Added a new feature'
  4. Push to your branch: git push origin feature-name
  5. Open a Pull Request

About

This is a easy template to build an Discord Bot using LLM models, to use into your servers and run personalized commands.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors