Skip to main content

CLI tool and Python library for Discord user lookup

Project description

Discord Lookup Tool

CI Python License Docker

Description

Discord Lookup Tool is a command-line interface (CLI) application and Python library for querying user information from Discord's official API. It provides detailed user profiles including avatar, banner, account creation date, badges, and more.

Features

  • User lookup by ID - Get complete user information from Discord
  • Batch processing - Process multiple user IDs from a file with progress bar
  • Multiple output formats - Table (colorful), JSON, and CSV
  • Professional logging - DEBUG, INFO, WARNING, ERROR levels with --verbose flag
  • Error handling - Comprehensive error handling for API errors, rate limiting, and network issues
  • Docker support - Containerized application for easy deployment
  • CI/CD - Automated testing with GitHub Actions

Technologies

  • Python 3.10+
  • Requests library for HTTP calls
  • Colorama for terminal colors
  • TQDM for progress bars
  • Pytest for unit testing
  • Docker for containerization
  • GitHub Actions for CI/CD

Installation

Local Installation

# Clone the repository
git clone https://github.com/Paulouuul/discord-lookup.git
cd discord-lookup

# Create virtual environment
python -m venv venv

# Activate virtual environment
# Windows:
venv\Scripts\activate
# Linux/Mac:
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Create .env file with your bot token
echo DISCORD_BOT_TOKEN=your_token_here > .env

Docker Installation

Build the image

docker build -f Dockerfile.cli -t discord-lookup-cli .

Run with volume for .env access

docker run --rm -v "$(pwd):/app" discord-lookup-cli USER_ID

Usage

Basic user lookup (table format)

python -m discord_lookup.cli USER_ID

JSON output

python -m discord_lookup.cli USER_ID --output json

CSV output

python -m discord_lookup.cli USER_ID --output csv

Save output to file

python -m discord_lookup.cli USER_ID --output json --save output.json

Batch processing

python -m discord_lookup.cli --batch ids.txt

Batch with JSON output and save

python -m discord_lookup.cli --batch ids.txt --output json --save results.json

Verbose mode (debug logs)

python -m discord_lookup.cli USER_ID --verbose

Disable colors

python -m discord_lookup.cli USER_ID --no-color

Output Examples

Table Format

2026-04-20 19:58:43,191 - INFO - Buscando usuário: 123456789012345678
2026-04-20 19:58:43,515 - INFO - USUARIO ENCONTRADO!
ID: 123456789012345678
Username: exemplo_usuario
Discriminator: #1234
Nome Completo: exemplo_usuario#1234
Avatar: https://cdn.discordapp.com/avatars/123456789012345678/avatar_hash.png?size=512
Bot: Nao
Data Criacao: 01/01/2021 12:00
Badges/Flags: 131072
Global Name: Exemplo Nome

JSON Format

{
  "id": "123456789012345678",
  "username": "exemplo_usuario",
  "discriminator": "1234",
  "global_name": "Exemplo Nome",
  "avatar_url": "https://cdn.discordapp.com/avatars/123456789012345678/avatar_hash.png?size=512",
  "banner_url": null,
  "is_bot": false,
  "created_at": "01/01/2021 12:00",
  "public_flags": 131072
}

CSV Format

id,username,discriminator,global_name,avatar_url,banner_url,is_bot,created_at,public_flags
123456789012345678,exemplo_usuario,1234,Exemplo Nome,https://cdn.discordapp.com/avatars/123456789012345678/avatar_hash.png?size=512,,False,01/01/2021 12:00,131072

Batch Output (JSON)

{
  "total": 2,
  "success_count": 2,
  "error_count": 0,
  "results": [
    {
      "user_id": "123456789012345678",
      "success": true,
      "data": {
        "id": "123456789012345678",
        "username": "usuario1",
        "discriminator": "1234",
        "global_name": "Nome Um",
        "avatar_url": "https://cdn.discordapp.com/avatars/123456789012345678/avatar_hash.png?size=512",
        "created_at": "01/01/2021 12:00",
        "is_bot": false
      }
    },
    {
      "user_id": "876543210987654321",
      "success": true,
      "data": {
        "id": "876543210987654321",
        "username": "usuario2",
        "discriminator": "5678",
        "global_name": "Nome Dois",
        "avatar_url": "https://cdn.discordapp.com/avatars/876543210987654321/avatar_hash.png?size=512",
        "created_at": "15/03/2022 18:30",
        "is_bot": false
      }
    }
  ]
}

Batch Output (CSV)

user_id,success,username,discriminator,global_name,avatar_url,banner_url,created_at,is_bot,error
123456789012345678,SUCCESS,usuario1,1234,Nome Um,https://cdn.discordapp.com/avatars/123456789012345678/avatar_hash.png?size=512,,01/01/2021 12:00,False,
876543210987654321,SUCCESS,usuario2,5678,Nome Dois,https://cdn.discordapp.com/avatars/876543210987654321/avatar_hash.png?size=512,,15/03/2022 18:30,False,
999999999999999999,ERROR,,,,,,,User not found

Help

python -m discord_lookup.cli --help

As Python Library

from discord_lookup import DiscordClient

client = DiscordClient(token="your_bot_token")
user = client.get_user("123456789012345678")
print(user.username)
print(user.created_at)

Configuration

1. Getting a Discord Bot Token

Follow these steps to obtain a Discord bot token:

  1. Go to Discord Developer Portal
  2. Click on "New Application" and give it a name
  3. Go to the "Bot" tab in the left sidebar
  4. Click "Add Bot" and confirm
  5. Under the "Token" section, click "Copy" to copy your bot token
  6. Enable the following Privileged Gateway Intents if needed:
    • Server Members Intent (for member information)
    • Message Content Intent (for message processing)

Important: Keep your token secure. Never share it or commit it to version control.

2. Create a .env file in the project root:

DISCORD_BOT_TOKEN=your_discord_bot_token_here

Project Structure

discord-lookup/
├── .github/
│   └── workflows/
│       └── ci.yml          # GitHub Actions CI/CD
├── discord_lookup/         # Main package
│   ├── __init__.py
│   ├── cli.py              # Command-line interface
│   ├── client.py           # Discord API client
│   ├── formatters.py       # JSON and CSV formatters
│   ├── models.py           # Data models
│   └── utils.py            # Utility functions
├── tests/                  # Unit tests
│   ├── __init__.py
│   ├── test_client.py
│   ├── test_formatters.py
│   ├── test_models.py
│   └── test_utils.py
├── .dockerignore           # Docker ignore file
├── .gitignore              # Git ignore file
├── Dockerfile.cli          # Docker configuration
├── README.md               # This file
└── requirements.txt        # Python dependencies

Running Tests

Run all tests

pytest tests/ -v

Run with coverage report

pytest tests/ --cov=discord_lookup --cov-report=term

Run specific test file

pytest tests/test_formatters.py -v

License

This project is licensed under the MIT License - see below for the full license text.

MIT License

Copyright (c) 2026 Paulo Ricardo Tebet Lyrio

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Author

Paulo Ricardo Tebet Lyrio

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

discord_lookup-1.1.7.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

discord_lookup-1.1.7-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file discord_lookup-1.1.7.tar.gz.

File metadata

  • Download URL: discord_lookup-1.1.7.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for discord_lookup-1.1.7.tar.gz
Algorithm Hash digest
SHA256 beabb8040cae8a3e432a123acee3eafd9324e4cfca398745dddbb1d894f732a6
MD5 0da1effab66d98199f50660d09e95b65
BLAKE2b-256 39c8b8c1f61e44ad5d3efebea00477e3c4d35ade7c4eefb4ce608963a4f03d80

See more details on using hashes here.

File details

Details for the file discord_lookup-1.1.7-py3-none-any.whl.

File metadata

  • Download URL: discord_lookup-1.1.7-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for discord_lookup-1.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 606a91e675e2144fcc37da57f57e7ae6390ee2f893f31937d6d57805222fead5
MD5 a6f0b1f03b13ba3a4dd2f784f246c1d9
BLAKE2b-256 93f26dd41a6c9947625349c3d0ed557b338d1fe1ef6e1888305da562e60c8836

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page