Betterbot
A modern, event-driven bot framework for Python, designed for simplicity and flexibility.
Install
Install via pip:
pip install betterbot
How to Use
Import the Setup module and initialize your bot:
from betterbot import Setup
Example Bot Script
import asyncio
import json
from betterbot import Setup, Events, Intents
# Load bot token from configuration
with open("config.json") as f:
config = json.load(f)
TOKEN = config["TOKEN"]
class Bot:
def __init__(self):
self.bot = Setup(TOKEN, intents=Intents.all)
self.bot.debug = True # Enable detailed debug logs
self.rest = self.bot.rest_client
self.bot_username = None
self.event = self.bot.event
async def main(self):
# Register event handlers
await self.event.register(Events.BOT_READY, self.on_ready) # You can register multiple handlers per event.
await self.event.register(Events.MESSAGE_CREATE, self.on_message)
await self.bot.start()
# -----------------------
# Event Handlers
# -----------------------
async def on_ready(self, username, es):
self.bot_username = username
print(f"Logged in as {username}")
# Create a guild slash command
# Es stands for Event-Send use it in response to events/command events
await es.create_guild_command(
self.test_command,
guild_id=GUILD_ID,
name="testrest",
description="some example REST endpoints"
)
async def on_message(self, username, content, channel_id):
if username == self.bot_username:
return
print(f"{username}: {content}")
if content.lower() == "example rest":
await self.test_rest_methods()
# -----------------------
# Slash Command Handler
# -----------------------
async def test_command(self, es):
# Es is the prefered way to respond to events you can do it manually but that is not recommended
# Immediately respond to the interaction
await es.respond_message(content="Hello, it is starting!")
await self.test_rest_methods()
async def test_rest_methods(self):
# -----------------------
# Channel Methods
# -----------------------
await self.rest.send_message(CHANNEL_ID, "Hello from Betterbot REST test!")
messages = await self.rest.get_messages(CHANNEL_ID)
if messages:
msg_id = messages[0]["id"]
await self.rest.typing(CHANNEL_ID)
await self.rest.add_reaction(CHANNEL_ID, msg_id, "👍")
await self.rest.remove_reaction(CHANNEL_ID, msg_id, "👍")
await self.rest.pin_message(CHANNEL_ID, msg_id)
await self.rest.unpin_message(CHANNEL_ID, msg_id)
# -----------------------
# Guild Methods
# -----------------------
guild_info = await self.rest.get_guild_info(GUILD_ID)
members = await self.rest.get_guild_members(GUILD_ID, limit=5)
roles = await self.rest.get_guild_roles(GUILD_ID)
print("REST test complete!")
# -----------------------
# Run Bot
# -----------------------
asyncio.run(Bot().main())
Metadata
Release files for Betterbot 6.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| betterbot-6.1.0.tar.gz | 38.1 kB | Without provenance | Details for betterbot-6.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| betterbot-6.1.0-py3-none-any.whl | Python 3 | none | any | Details for betterbot-6.1.0-py3-none-any.whl |
Total release size: 97.7 kB
Release files / betterbot-6.1.0.tar.gz
| Download URL | betterbot-6.1.0.tar.gz |
|---|---|
| Size | 38.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bf5e4c57f594b8db49fc268986ff6642caf13e85983d05626bfa5587d9a56047
|
|
BLAKE2b-256 checksum How to use checksums |
0b9ddc6ece6582dbe2183dc0eec4611888d37694203983357d9561bc43ea2ccd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / betterbot-6.1.0-py3-none-any.whl
| Download URL | betterbot-6.1.0-py3-none-any.whl |
|---|---|
| Size | 59.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
576141aef6e748f1977aa91263572485a42e1ab9235cbe2ecbc12edf568b83ca
|
|
BLAKE2b-256 checksum How to use checksums |
58df91da5970220e9ac96387418c4f491a2157e938d67ae798761a8f30265d39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for Betterbot 6.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.