Skip to content

A discord bot created using discord-py for a private server. The bot was built with different features, such as a translator, wiki inquiry, and dice rolling.

License

Notifications You must be signed in to change notification settings

NathanielCarballo/DiscordBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

DiscordBot — Python (discord.py) with Translate, Wiki, and Chat Template

A lightweight Discord bot built with Python and discord.py. It supports:

  • Translation via googletrans
  • Wikipedia summaries
  • A simple chatbot powered by chatbotTemplate.template
  • Clean embeds for longer replies

Command prefix: ~ (the bot only processes messages that start with ~).


Tech Stack

  • Python: 3.10+
  • Libraries: discord.py, googletrans==4.0.0-rc1, wikipedia, requests, python-dotenv (recommended)
  • Patterns: commands extension, async event loop, simple embed pagination

Project Structure

DiscordBot/
├─ translatorBot.py                 # entrypoint
├─ chatbotTemplate/
│  └─ chatbotTemplate.template      # template consumed by the chatbot
├─ LICENSE
└─ README.md

Setup

1) Create a Discord application & bot

  1. Go to the Discord Developer Portal → Applications → New Application
  2. Add a Bot, copy its token, and enable Message Content Intent
  3. OAuth2 → URL Generator → select bot scope + permissions → invite the bot to your server

2) Install dependencies

python -m venv .venv
# Windows
. .venv\Scripts\activate
# macOS/Linux
# source .venv/bin/activate

pip install discord.py googletrans==4.0.0-rc1 wikipedia requests python-dotenv

3) Configure your token

Option A (quick): in translatorBot.py, replace

bot.run('insertTokenHere')

with your real token string.

Option B (recommended): use a .env file:

  1. Create .env:
    DISCORD_TOKEN=your-bot-token-here
    
  2. At the top of translatorBot.py:
    import os
    from dotenv import load_dotenv
    load_dotenv()
    TOKEN = os.getenv("DISCORD_TOKEN")
    # ...
    bot.run(TOKEN)

Never commit .env to git; add it to .gitignore.

4) Run the bot

python translatorBot.py

If it starts correctly, the console will print the logged-in user.


Usage (examples)

~translate en hola mundo
~translate es "good morning, travelers"

~wiki event loop
~wiki texas barbecue

~chat what is polymorphism?

All commands must start with ~ due to the prefix gate in on_message.


Notes

  • Embeds: long wiki summaries are split into multiple embeds (2,048 char limit per embed).
  • Chatbot: @register_call("whoIs") bridges to Wikipedia summaries when the template calls it.
  • Intents: make sure Message Content Intent is enabled both in the portal and in code if you set custom Intents.

Roadmap

  • Convert text commands to slash commands (app_commands)
  • Add per-guild config (prefix/language) and better error messages
  • Add retries/backoff + structured logging for external API calls
  • Unit tests for wiki/translate helpers

License

See LICENSE.

About

A discord bot created using discord-py for a private server. The bot was built with different features, such as a translator, wiki inquiry, and dice rolling.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages