Discord Bot Helper 🤖
A modern Python library for building Discord bots with slash commands and automatic configuration.
Features ✨
- ⚙️ Automatic configuration wizard (
dbh-init) - 🔄 Slash command synchronization
- 🧩 Built-in cog loader
- 📝 Smart logging system
- 🔒 Permission handling
- 📦 Auto-dependency installation
Installation 💻
pip install git+https://github.com/KeiraOMG0/discord-bot-helper.git
Quick Start 🚀 Initialize Configuration:
dbh-init
Follow prompts to set up your bot token and preferences
Create bot.py:
from discord_bot_helper import DiscordBotHelper
import discord
bot = DiscordBotHelper()
@bot.tree.command(name="ping", description="Check bot latency")
async def ping(interaction: discord.Interaction):
await interaction.response.send_message(f"Pong! {round(bot.latency*1000)}ms")
if __name__ == "__main__":
bot.run_bot()
Run Your Bot:
python bot.py
Command Types 📜
Slash Commands (Recommended)
from discord import app_commands
@bot.tree.command(name="hello", description="Greet a user")
@app_commands.describe(user="User to greet")
async def hello(interaction: discord.Interaction, user: discord.User):
await interaction.response.send_message(f"Hello {user.mention}!")
Prefix Commands (Legacy)
@bot.command()
async def ping(ctx):
await ctx.send(f"Pong! {round(bot.latency*1000)}ms")
Cog System 🧩 Create cogs/moderation.py:
import discord
from discord import app_commands
from discord.ext import commands
class Moderation(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
@app_commands.command(name="clear", description="Clear messages")
@app_commands.checks.has_permissions(manage_messages=True)
async def clear(self, interaction: discord.Interaction, amount: int):
await interaction.response.defer(ephemeral=True)
deleted = await interaction.channel.purge(limit=amount)
await interaction.followup.send(f"Cleared {len(deleted)} messages", ephemeral=True)
async def setup(bot: commands.Bot):
await bot.add_cog(Moderation(bot))
Cogs automatically load when:
Placed in cogs/ directory
use_cogs enabled in config
File follows *.py naming
Permissions 🔒 Slash Command Permissions
@app_commands.checks.has_permissions(manage_messages=True)
@app_commands.checks.is_owner()
Prefix Command Permissions
@commands.has_permissions(kick_members=True)
@commands.is_owner()
Configuration ⚙️
Your config.json or .env file will contain:
{
"token": "YOUR_BOT_TOKEN",
"prefix": "!",
"sync_commands": true,
"use_cogs": true
}
Example Bot 🌟
from discord_bot_helper import DiscordBotHelper
import discord
class MyBot(DiscordBotHelper):
async def setup_hook(self):
await self.load_cogs()
await self.tree.sync()
bot = MyBot()
@bot.tree.command(name="server", description="Show server info")
async def server(interaction: discord.Interaction):
embed = discord.Embed(title=interaction.guild.name)
embed.add_field(name="Members", value=interaction.guild.member_count)
await interaction.response.send_message(embed=embed)
if __name__ == "__main__":
bot.run_bot()
Troubleshooting ⚠️ Common Issues:
Missing Permissions: Ensure bot has correct permissions in server
Command Sync Issues: Use await bot.tree.sync() after cog loading
Token Errors: Verify token in config.json/.env
Intents Issues: Enable required intents in Discord Developer Portal
Contributing 🤝 Fork the repository
Open Pull Request
License 📄 MIT License - See LICENSE
Metadata
Release files for discord-bot-helper 1.0.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 |
|---|---|---|---|---|
| discord_bot_helper-1.0.0.tar.gz | 6.6 kB | Without provenance | Details for discord_bot_helper-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| discord_bot_helper-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for discord_bot_helper-1.0.0-py3-none-any.whl |
Total release size: 14.8 kB
Release files / discord_bot_helper-1.0.0.tar.gz
| Download URL | discord_bot_helper-1.0.0.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
14aceebc31674b00cc7300f88ddca345dabefd28103590c85c71c5fc40216666
|
|
BLAKE2b-256 checksum How to use checksums |
6eb586cceb0ec0f63304e086fc555905bcf555e18aa3049343a5b9ea9ee408bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / discord_bot_helper-1.0.0-py3-none-any.whl
| Download URL | discord_bot_helper-1.0.0-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6f2ad3309ea2c8c9f87f871cd21a7ec7c6263c1f45e2797c56fcea432118fb0f
|
|
BLAKE2b-256 checksum How to use checksums |
73417e1b0ca124bd773920150db76a9e9f6b71df871d3a1cb2dd553911448022
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Security for discord-bot-helper 1.0.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.