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
-
Install the required dependencies:
pip install httpx websockets
-
Clone or download the GhostCord repository:
git clone https://github.com/xAI/GhostCord.git cd GhostCord
-
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ghostcord-0.1.0.tar.gz.
File metadata
- Download URL: ghostcord-0.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e51e96c4ced6992fe350733109b94d07381e4f54a41a44a7c54fe14e3020da4c
|
|
| MD5 |
3de50f4d70b2c46099a04e0e619b6498
|
|
| BLAKE2b-256 |
e12a19140c9789c28d3d040c0a2ccdb72692028664715807d81f51c272b6aa83
|
File details
Details for the file ghostcord-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ghostcord-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6d1a136808fd1902fdbb8422f88e678b80e296adf7d3b4e5b1cd21e1f9942c4
|
|
| MD5 |
9fadc7a2dbc5a25f96463d60d72df015
|
|
| BLAKE2b-256 |
134aa7b8de8437273cc8e31183ccd7753730f2ce61a8a90b9073b29efa7593fd
|