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

# Quick Start: Run Your First alterself Discord Selfbot

> Install alterself, retrieve your Discord user token from browser Local Storage, and run a working selfbot with a ping command in minutes.

This guide walks you through everything you need to go from a blank Python file to a running alterself selfbot. By the end you will have alterself installed, your Discord token retrieved securely, and a working bot that responds to a `.ping` command with live latency data. The whole process takes about five minutes.

<Steps>
  <Step title="Install alterself">
    Make sure you have Python 3.10 or newer, then install alterself from PyPI:

    ```bash theme={null}
    pip install alterself
    ```

    Verify the installation by checking the version:

    ```bash theme={null}
    python -m alterself --version
    ```

    You should see the current version number printed to your terminal. If you see a `ModuleNotFoundError` instead, double-check that you are running the `pip` that belongs to the Python interpreter you intend to use.
  </Step>

  <Step title="Retrieve your Discord token">
    alterself connects to Discord as your user account, so it needs your personal user token: not a bot token.

    1. Open Discord in your **web browser** (discord.com) and log in.
    2. Press **F12** (or **Cmd + Option + I** on macOS) to open DevTools.
    3. Click the **Application** tab, then expand **Storage → Local Storage** in the left sidebar.
    4. Click the **`https://discord.com`** entry to open the key/value table.
    5. Find the row with the key **`token`** and copy its value. That value is your token.

    <Warning>
      Your user token is the master key to your Discord account. Never paste it into a chat message, commit it to a Git repository, or share it with anyone. Store it in an environment variable (see the [Installation guide](/installation) for details). If you accidentally expose your token, change your Discord password immediately. Discord will invalidate the old token.
    </Warning>
  </Step>

  <Step title="Create your first selfbot">
    Create a new file called `bot.py` and paste in the following code, replacing `YOUR_USER_TOKEN` with the token you copied in the previous step:

    ```python bot.py theme={null}
    import alterself

    bot = alterself.Client(
        token  = "YOUR_USER_TOKEN",
        prefix = ".",
    )

    @bot.on_event
    async def on_ready():
        print(f"[+] Ready - logged in as {bot.me.username}#{bot.me.discriminator}")
        print(f"[+] Build number: {bot._spoof.build_number}")
        print(f"[+] Spoofed UA: {bot._spoof.profile.user_agent}")

    @bot.command()
    async def ping(ctx):
        await ctx.reply(f"pong | latency {bot.latency * 1000:.1f} ms")

    bot.run()
    ```

    Here is what each part does:

    * **`alterself.Client`**: the central object that owns the gateway connection, the HTTP session, and the spoofing engine.
    * **`prefix = "."`**: every message starting with `.` will be checked against your registered commands.
    * **`@bot.on_event` / `on_ready`**: runs once the gateway handshake is complete and `bot.me` is populated.
    * **`@bot.command()` / `ping`**: registers `.ping` as a command. `ctx.reply()` sends a message in the same channel.
    * **`bot.run()`**: starts the event loop, connects to the gateway, and blocks until you stop the process.
  </Step>

  <Step title="Run it and verify">
    Start the selfbot from your terminal:

    ```bash theme={null}
    python bot.py
    ```

    You should see output similar to this within a few seconds:

    ```text theme={null}
    [+] Ready - logged in as YourName#0001
    [+] Build number: 322050
    [+] Spoofed UA: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ...
    ```

    Now open Discord, navigate to any channel your account can write in, and send `.ping`. The selfbot will reply with something like:

    ```text theme={null}
    pong | latency 42.3 ms
    ```

    Press **Ctrl + C** in your terminal to stop the selfbot gracefully.
  </Step>
</Steps>

## What to try next

Now that your selfbot is running, here are the natural next steps:

* **Understand the Client**: learn about the gateway lifecycle, session state, and the properties available on `bot.me` in the [Client concept guide](/concepts/client).
* **Build more commands**: explore argument parsing, error handling, and checks in the [Commands concept guide](/concepts/commands).
* **See real examples**: browse complete, copy-paste-ready selfbot scripts in the [Examples guide](/guides/examples).

<Tip>
  Store your token in the `DISCORD_TOKEN` environment variable rather than hardcoding it in `bot.py`. Replace `token = "YOUR_USER_TOKEN"` with `token = os.environ["DISCORD_TOKEN"]` and run `export DISCORD_TOKEN=your_token_here` in your terminal before starting the bot. Your token will never appear in source code.
</Tip>
