Skip to content

mycoderisyad/PoligotBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

PoligotBot - Bot Discord Latihan Bahasa Multibahasa

Bot Discord untuk latihan bahasa dengan fitur percakapan real-time, terjemahan multibahasa, dan voice chat AI menggunakan Gemini AI dan Google Cloud Speech.

Fitur Utama

  • Translator Multibahasa - Terjemahan akurat dengan Gemini AI ke 5 bahasa (ID, EN, JA, KO, ZH)
  • Percakapan Real-time - Chat dengan AI yang memiliki memory per user
  • Mode Pembelajaran - Feedback grammar dan vocabulary dengan analisis mendalam
  • Voice Chat AI - Percakapan suara real-time dengan AI menggunakan Google Cloud Speech
  • Text-to-Speech AI - Konversi teks ke suara menggunakan Gemini AI (phonetic analysis)
  • Pengaturan Bahasa - Preferensi bahasa per user untuk pengalaman personal

Arsitektur Sistem

[Discord User (Text/Voice Input)]
           โ†“
[Discord Bot (Node.js + discord.js v14)]
           โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚          Core Services                  โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  โ€ข Gemini AI (Chat, Translation,       โ”‚
โ”‚    Grammar Check, Learning, TTS)       โ”‚
โ”‚  โ€ข Google Cloud Speech-to-Text         โ”‚
โ”‚  โ€ข @discordjs/voice (Voice Handling)   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ†“
[Discord Response (Text/Audio/Embed)]

Teknologi yang Digunakan

Komponen Teknologi
Discord Bot discord.js v14, Node.js
AI Language Processing Google Gemini AI (gemini-1.5-flash)
Translation Google Gemini AI
Text-to-Speech Google Gemini AI (phonetic analysis)
Speech-to-Text Google Cloud Speech-to-Text
Voice Handling @discordjs/voice, prism-media, ffmpeg

Quick Start

Prerequisites

  1. Node.js (v16 atau lebih tinggi)
  2. Discord Bot Token - Discord Developer Portal
  3. Google Gemini AI API Key - Google AI Studio
  4. Google Cloud Project dengan Speech API enabled - Google Cloud Console
  5. Google Cloud Service Account Key (JSON file)

Installation

  1. Clone repository
git clone <repository-url>
cd poligot-bot
  1. Install dependencies
npm install
  1. Setup environment variables
# Copy the example file and configure
cp .env.example.txt .env
# Edit .env file dengan konfigurasi Anda
  1. Configure .env file
# Discord Bot Configuration
DISCORD_TOKEN=your_discord_bot_token_here

# Bot Command Prefix (dapat diubah sesuai keinginan)
# Contoh: !, >, $, &, atau karakter lain
PREFIX=>

# Gemini AI Configuration  
GEMINI_API_KEY=your_gemini_api_key_here

# Google Cloud Speech Configuration
GOOGLE_CLOUD_PROJECT_ID=your_google_cloud_project_id
GOOGLE_CLOUD_KEY_FILE=./google-cloud-key.json

Note: Prefix bisa diubah sesuai keinginan di .env. Semua contoh command di bawah menggunakan ! tapi sesuaikan dengan PREFIX yang Anda set.

  1. Setup Google Cloud

    • Buat project di Google Cloud Console
    • Enable Speech-to-Text API
    • Buat Service Account dan download JSON key
    • Simpan JSON key sebagai google-cloud-key.json di root folder
  2. Run the bot

npm start
# atau untuk development
npm run dev

Commands

Percakapan Real-time

  • !chat <pesan> - Percakapan dengan AI (ada memory)
  • !chat clear - Hapus riwayat percakapan
  • !chat history - Lihat riwayat percakapan

Translator Multibahasa

  • !translate <teks> - Terjemahan otomatis
  • !translate <kode> <teks> - Terjemahan ke bahasa tertentu
  • !tr - Alias untuk translate

Pembelajaran Bahasa

  • !belajar <teks> - Feedback pembelajaran multibahasa
  • !grammar <teks> - Grammar check multibahasa
  • !learn - Alias untuk belajar

Pengaturan Bahasa

  • !language - Lihat/ubah bahasa preferensi
  • !language <kode> - Set bahasa (id, en, ja, ko, zh)
  • !lang - Alias untuk language

Voice Chat AI

  • !voicechat start - Mulai percakapan suara dengan AI
  • !voicechat stop - Stop voice chat
  • !voicechat status - Status voice session
  • !vc - Alias untuk voicechat

Voice & TTS

  • !join - Bot masuk voice channel
  • !leave - Bot keluar voice channel
  • !tts <teks> - Text-to-speech dengan Gemini AI

Utilitas

  • !ping - Cek status dan latency
  • !help - Panduan lengkap

Bahasa yang Didukung

Kode Bahasa Flag Google Cloud Code
id Indonesian ๐Ÿ‡ฎ๐Ÿ‡ฉ id-ID
en English ๐Ÿ‡บ๐Ÿ‡ธ en-US
ja Japanese ๐Ÿ‡ฏ๐Ÿ‡ต ja-JP
ko Korean ๐Ÿ‡ฐ๐Ÿ‡ท ko-KR
zh Chinese ๐Ÿ‡จ๐Ÿ‡ณ zh-CN

Contoh Penggunaan

# Ubah bahasa preferensi ke Jepang
!language ja

# Chat dalam bahasa Jepang
!chat ใ“ใ‚“ใซใกใฏ๏ผๅ…ƒๆฐ—ใงใ™ใ‹๏ผŸ

# Mulai voice chat AI
!voicechat start

# Terjemahan Korea ke Inggris
!translate en ์•ˆ๋…•ํ•˜์„ธ์š”

# Belajar bahasa Mandarin
!belajar ๆˆ‘ๆƒณๅญฆไน ไธญๆ–‡

# Grammar check
!grammar I are happy

# TTS dengan Gemini AI
!tts ja ใ“ใ‚“ใซใกใฏใ€ไปŠๆ—ฅใฏใ„ใ„ๅคฉๆฐ—ใงใ™ใญ

Development

Project Structure

poligot-bot/
โ”œโ”€ bot/
โ”‚  โ”œโ”€ index.js              # Main bot entry point
โ”‚  โ””โ”€ commands/             # Command implementations
โ”‚     โ”œโ”€ help.js            # Help command
โ”‚     โ”œโ”€ ping.js            # Ping command
โ”‚     โ”œโ”€ chat.js            # Chat with memory
โ”‚     โ”œโ”€ translate.js       # Translation (tr alias)
โ”‚     โ”œโ”€ belajar.js         # Learning mode (learn alias)
โ”‚     โ”œโ”€ grammar.js         # Grammar check
โ”‚     โ”œโ”€ language.js        # Language settings (lang alias)
โ”‚     โ”œโ”€ voicechat.js       # Voice chat AI (vc alias)
โ”‚     โ”œโ”€ join.js            # Join voice
โ”‚     โ”œโ”€ leave.js           # Leave voice
โ”‚     โ””โ”€ tts.js             # Text-to-speech with Gemini AI
โ”œโ”€ services/
โ”‚  โ”œโ”€ gemini.js             # Gemini AI service
โ”‚  โ””โ”€ googleCloudSpeech.js  # Google Cloud Speech service
โ”œโ”€ temp/                    # Temporary audio files
โ”œโ”€ package.json
โ”œโ”€ .env.example.txt         # Environment template
โ”œโ”€ .gitignore
โ””โ”€ README.md

Adding New Commands

  1. Create new file in bot/commands/
  2. Follow this template:
const { EmbedBuilder } = require('discord.js');
const GeminiAI = require('../../services/gemini');

module.exports = {
  data: {
    name: 'commandname',
    description: 'Command description',
  },
  async execute(message, args, client) {
    const gemini = new GeminiAI();
    
    try {
      // Command logic here
      const response = await gemini.generateText(prompt);
      
      const embed = new EmbedBuilder()
        .setColor(0x4285f4)
        .setTitle('Command Title')
        .setDescription(response.content)
        .setFooter({ text: 'Powered by Gemini AI' });
        
      await message.reply({ embeds: [embed] });
    } catch (error) {
      console.error('Command error:', error);
      await message.reply('โŒ Terjadi error.');
    }
  },
};

๐Ÿ”ง Configuration

Environment Variables

Variable Description Required
DISCORD_TOKEN Discord bot token โœ…
PREFIX Command prefix (default: !) โœ…
GEMINI_API_KEY Google Gemini AI API key โœ…
GOOGLE_CLOUD_PROJECT_ID Google Cloud project ID โœ…
GOOGLE_CLOUD_KEY_FILE Path to service account JSON โœ…

Google Cloud Setup

  1. Create a new project in Google Cloud Console
  2. Enable the following APIs:
    • Cloud Speech-to-Text API
  3. Create a service account:
    • Go to IAM & Admin > Service Accounts
    • Create new service account
    • Grant roles: Speech Admin, Cloud Speech Client
    • Download JSON key file
  4. Place the JSON file in project root as google-cloud-key.json

Features

Smart Translation

  • Auto-detect source language
  • Context-aware translation
  • Support for 5 major languages
  • Confidence scoring

AI Learning Assistant

  • Grammar correction with explanations
  • Vocabulary suggestions
  • Alternative expressions
  • Natural conversation practice

Voice Chat AI

  • Real-time speech recognition
  • AI conversation with voice
  • Speech-to-text processing
  • Session management

Intelligent TTS

  • Phonetic analysis with Gemini AI
  • Multi-language support
  • Context-aware speech generation
  • Audio simulation

Memory System

  • Per-user chat history
  • Context retention
  • Conversation continuity
  • History management

Performance

  • Response Time: < 2 seconds for text commands
  • Voice Latency: < 3 seconds for voice processing
  • Concurrent Users: Supports multiple users simultaneously
  • Memory Usage: Optimized for long-running instances

Contributing

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Acknowledgments

Support

Jika Anda mengalami masalah atau memiliki pertanyaan:

  1. Check Issues untuk masalah yang sudah diketahui
  2. Buat issue baru dengan detail lengkap
  3. Sertakan log error dan konfigurasi (tanpa API keys)

PoligotBot v3.0 - Powered by Gemini AI & Google Cloud Speech

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors