SelfBot class provides a Discord bot wrapper that sees all messages and processes commands for the owner.
SelfBot
Discord bot token. Falls back to
DISCORD_TOKEN environment variable if not provided.Command prefix for the bot
Attributes
The Discord bot token used for authentication
The underlying discord.py Bot instance
The command prefix string
Methods
command
Register a command handler.Command name (defaults to function name)
Additional command decorator arguments
Command decorator function
Example
event
Register an event handler.Async function to handle the event
Event decorator function
Example
run
Start the bot and connect to Discord.Example
Built-in Events
The SelfBot class registers these events by default:on_ready
Triggered when the bot successfully connects to Discord.on_message
Triggered for every message the bot can see (not just mentions).Usage Example
Configuration
The bot can be configured using: Environment Variables:DISCORD_TOKEN: Discord bot token (used iftokenparameter is None)
token: Override environment variableprefix: Custom command prefix
Features
- Sees all messages in channels (not just mentions)
- Processes commands with custom prefix
- Built on discord.py commands framework
- Self-bot mode enabled
- Automatic token loading from environment