> ## Documentation Index
> Fetch the complete documentation index at: https://docs.guilt.icu/llms.txt
> Use this file to discover all available pages before exploring further.

# alterself: Build and Run Discord Selfbots in Python

> alterself is a Python library for building Discord selfbots. Automate your account with commands, events, HTTP calls, and fingerprint spoofing.

alterself is a Python library that lets you automate your own Discord account: without bots, without OAuth, and without giving up control. You write event handlers and commands the same way you would with a traditional bot framework, but alterself connects as your user account, spoofs a realistic browser fingerprint, and speaks Discord's private API on your behalf. Whether you want to automate repetitive tasks, build personal productivity tools, or experiment with Discord's gateway protocol, alterself gives you the primitives to do it cleanly.

## Key Features

<CardGroup cols={2}>
  <Card title="Command Framework" icon="terminal">
    Declare commands with a single `@bot.command()` decorator. alterself handles prefix parsing, argument splitting, and dispatching so you can focus on what the command actually does.
  </Card>

  <Card title="Gateway Events" icon="bolt">
    Subscribe to any Discord gateway event, such as `on_ready`, `on_message`, `on_presence_update`, and more, using the `@bot.on_event` decorator. Events are dispatched asynchronously via `asyncio`.
  </Card>

  <Card title="HTTP Client" icon="globe">
    A built-in async HTTP client wraps Discord's private REST API. Send messages, edit your profile, manage relationships, and call any endpoint without dealing with raw HTTP or rate limits manually.
  </Card>

  <Card title="Spoofing Engine" icon="fingerprint">
    alterself automatically generates and injects a realistic browser fingerprint, including `User-Agent`, `X-Super-Properties`, build number, and client state, so your connection looks like a normal desktop client to Discord's servers.
  </Card>

  <Card title="Rich Presence" icon="gamepad">
    Set and update your Rich Presence activity programmatically. Display custom status text, images, timestamps, and party info to match whatever context your selfbot is running in.
  </Card>

  <Card title="Error Handling" icon="shield-exclamation">
    Structured exception types give you fine-grained control over HTTP errors, gateway disconnects, and command failures. Wrap your handlers with confidence, or let alterself's default handlers log and recover automatically.
  </Card>
</CardGroup>

## How It Works

At runtime, alterself revolves around a single `Client` object. You create a `Client` with your user token and a command prefix, then register event handlers and commands against it. When you call `bot.run()`, two things happen concurrently: a WebSocket connection opens to Discord's gateway (handling heartbeats, session resumption, and event dispatching), and an async HTTP session is initialised for outbound REST calls. Every inbound gateway event is decoded and routed to your registered handlers; every outbound action, such as replying to a message, changing your status, or calling an API endpoint, goes through the HTTP client. The spoofing engine runs transparently in the background, populating the headers and payloads that Discord expects to see from a real desktop client. You never need to think about the wire protocol: you just write Python.

<Note>
  alterself is intended for personal automation and educational exploration of Discord's API. Never share your user token with anyone or commit it to a public repository. Anyone who holds your token has full access to your account. Store it in an environment variable or a secrets manager and keep it private.
</Note>
