Skip to main content
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

Command Framework

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.

Gateway Events

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.

HTTP Client

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.

Spoofing Engine

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.

Rich Presence

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.

Error Handling

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.

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.
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.