Building a Discord Bot with ChatGPT and Google AI Scripts

I created two scripts for a Discord bot: one using ChatGPT and another leveraging Google AI Gemini. Here's a quick overview of the process and key details:

ChatGPT and Google AI Scripts

  • Initially, I used ChatGPT with free tokens. However, after running out of tokens and not saving screenshots, I decided to create another script, this time with Google AI Gemini.

  • Both scripts perform well, but Google AI Gemini offers a free option, making it a fantastic alternative.

Handling Discord's Output Limits

Discord imposes a 2000-character limit per message. To address this:

  • I used Python to check the length of outputs.

  • If the output exceeds the limit, the script automatically splits it into chunks of 2000 characters and sends them sequentially.

API Key Management

To run the bot:

  • You'll need to provide your own API keys for Discord and the AI service you choose.

  • API keys should be stored securely in a .env file for Python. This helps keep them safe and allows easy integration into your project.

Why Both AI Scripts?

  • ChatGPT: Offers robust capabilities and excellent natural language processing.

  • Google AI Gemini: Free and still delivers impressive performance, making it a great option for users without ChatGPT tokens.

Enjoy building and customizing your Discord bot! This setup ensures flexibility and scalability while providing the tools to manage Discord's limitations effectively.