Skip to main content

A lightweight, async Python library for controlling Discord user accounts (selfbot behavior).

Project description

⚠️ Disclaimer: This library is intended for educational and authorized use only. The developer is NOT responsible for any misuse or violation of Discord's Terms of Service (ToS). Using selfbots on Discord is against their ToS and may result in account termination. Use at your own risk.

GhostCord

GhostCord is a lightweight, async Python library for controlling Discord user accounts (selfbot behavior). It is designed to be modular, secure, and extensible, with zero external dependencies except httpx and websockets.

Features

  • Fully async with Python 3.8+ compatibility
  • Send, edit, delete messages, and add reactions
  • Read incoming DMs
  • Rich Presence support (custom activities, images, timers, buttons)
  • Smart rate limit handling
  • Secure token handling (never logged or printed)
  • Event system (on_ready, on_message, etc.)
  • Prefixed command handler (e.g., .ping, .say)
  • Automatic WebSocket reconnection
  • Clean logging system (info/debug/error levels)

Installation

  1. Install the required dependencies:

    pip install httpx websockets
    
  2. Clone or download the GhostCord repository:

    git clone https://github.com/xAI/GhostCord.git
    cd GhostCord
    
  3. Install the library:

    pip install .
    

Usage

Basic Example

Create a file bot.py:

import asyncio
from ghostcord import Client

client = Client(token="YOUR_TOKEN_HERE", prefix=".", log_level=20)

@client.event
async def on_ready():
    print(f"Logged in as {client.user}")

@client.command()
async def ping(message, args):
    await client.send_message(message.channel_id, "Pong!")

async def main():
    try:
        await client.connect()
    finally:
        await client.close()

if __name__ == "__main__":
    asyncio.run(main())

Run the bot:

python bot.py

Rich Presence Example

Set a custom Rich Presence:

import asyncio
from ghostcord import Client
import time

client = Client(token="YOUR_TOKEN_HERE", prefix=".", log_level=20)

@client.event
async def on_ready():
    print(f"Logged in as {client.user}")
    await client.presence.set_rich_presence(
        name="GhostCord",
        type=0,
        details="Running a selfbot",
        state="Developed by xAI",
        start_timestamp=int(time.time()),
        large_image="ghostcord_icon",
        large_text="GhostCord Library",
        buttons=[{"label": "Visit xAI", "url": "https://x.ai"}],
    )

async def main():
    try:
        await client.connect()
    finally:
        await client.close()

if __name__ == "__main__":
    asyncio.run(main())

Project Structure

GhostCord/
├── ghostcord/
│   ├── __init__.py
│   ├── client.py
│   ├── models.py
│   ├── utils.py
│   ├── errors.py
│   ├── presence.py
│   ├── events.py
│   ├── commands.py
│   └── ratelimit.py
├── examples/
│   ├── basic_bot.py
│   └── rich_presence.py
├── LICENSE
├── README.md
└── pyproject.toml

Contributing

Contributions are welcome! Please submit a pull request or open an issue on GitHub.

License

GhostCord is licensed under the MIT License. See the LICENSE file for details.

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

ghostcord-0.2.0.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

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

ghostcord-0.2.0-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file ghostcord-0.2.0.tar.gz.

File metadata

  • Download URL: ghostcord-0.2.0.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for ghostcord-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5c5a5ee40da51ea709200598daec6512c4722778a08d2188494b4c767818273e
MD5 6ade8c2b3c6b4130953abd4d8ced2276
BLAKE2b-256 25e88fd8e6c724a1eacb87dd380172534df44ead29531d13efe61563d2e44865

See more details on using hashes here.

File details

Details for the file ghostcord-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: ghostcord-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for ghostcord-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cda9dcbc971b3262fdcd5a2d58f60eeeac188156abefa1eac4f83ced23c92dd3
MD5 7806a1e5fe360dd6c1c6272facd46a56
BLAKE2b-256 455073143b43b052824257a3b4ee51cd75e8e4ec92d8750b13bb4441463fc3d4

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