A modern Discord bot built with Discord.py 2.5.2 for 2025, featuring slash commands, interactive UI components, comprehensive error handling, and a beautiful user interface.
- Modern Slash Commands: Uses Discord's native slash command system with autocomplete and validation
- Interactive UI: Beautiful buttons, modals, and interactive embed creation
- Modern Architecture: Built with Discord.py 2.5.2 using the latest async/await patterns
- Comprehensive Commands: Utility commands, embed creation, polls, and more
- Clean UI: Beautiful embeds with emojis and consistent styling
- Error Handling: Robust error handling with user-friendly messages
- Modular Design: Organized cog system for easy maintenance and expansion
- Secure Configuration: Environment variable-based configuration
- Logging: Comprehensive logging for debugging and monitoring
- Python 3.8 or higher
- A Discord bot application (Create one here)
-
Clone the repository
git clone <your-repo-url> cd oyasumi
-
Install dependencies
pip install -r requirements.txt
-
Configure the bot
# Copy the example environment file cp env.example .env # Edit .env with your bot's information # You need: # - TOKEN: Your bot's token from Discord Developer Portal # - OWNER_ID: Your Discord user ID
-
Run the bot
python run.py # OR python src/bot.py
-
Invite the bot to your server
- Go to the Discord Developer Portal
- Select your application β OAuth2 β URL Generator
- Select "bot" and "applications.commands" scopes
- Choose necessary permissions
- Use the generated URL to invite your bot
All commands use Discord's modern slash command system. Simply type /
in any text channel to see available commands!
/hello
- Greet the bot/ping
- Check bot latency and response time/botinfo
- Display bot information/serverinfo
- Show server information/userinfo [@user]
- Display user information/avatar [@user]
- Show user's avatar
/coinflip
- Flip a coin/roll [sides]
- Roll a dice (default: 6 sides, max: 100)/8ball <question>
- Ask the magic 8-ball/choose <choices>
- Choose between options (comma-separated)
/embed
- Interactive embed creator with buttons and modals/quickembed <message>
- Create a quick embed/say <message>
- Make the bot say something in an embed/announce <message>
- Create an announcement (requires manage messages)/poll <question> <option1> <option2> [option3] [option4] [option5]
- Create a poll with reactions/embedinfo [message_id]
- Get information about an embed/help
- Display help information about bot commands
/reload <cog>
- Reload a specific cog/sync
- Manually sync slash commands/shutdown
- Safely shutdown the bot
The bot uses environment variables for configuration. Create a .env
file in the root directory:
# Discord Bot Configuration
TOKEN=your_bot_token_here
OWNER_ID=your_discord_user_id_here
- Go to the Discord Developer Portal
- Create a new application or select an existing one
- Go to the "Bot" section
- Copy the token (keep this secret!)
- Enable Developer Mode in Discord (User Settings β Advanced β Developer Mode)
- Right-click on your username and select "Copy ID"
Your bot needs these permissions:
- Send Messages - To send responses
- Use Slash Commands - To register and use slash commands
- Embed Links - To send rich embeds
- Add Reactions - For poll functionality
- Read Message History - For embed info command
oyasumi/
βββ src/
β βββ bot.py # Main bot file with slash command setup
β βββ cogs/ # Bot commands organized in cogs
β βββ basic.py # Basic utility slash commands
β βββ embed.py # Embed-related slash commands with UI
βββ requirements.txt # Python dependencies
βββ env.example # Environment variables template
βββ run.py # Convenient startup script
βββ README.md # This file
βββ .gitignore # Git ignore file
Create commands using the @app_commands.command
decorator:
@app_commands.command(name='example', description='An example slash command')
@app_commands.describe(argument='Description of the argument')
async def example_command(self, interaction: discord.Interaction, argument: str):
"""An example slash command"""
embed = discord.Embed(
title="Example",
description=f"You provided: {argument}",
color=discord.Color.blue()
)
await interaction.response.send_message(embed=embed)
The bot supports Discord's modern UI components:
class MyView(discord.ui.View):
@discord.ui.button(label='Click Me!', style=discord.ButtonStyle.primary)
async def my_button(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_message("Button clicked!", ephemeral=True)
# Send with the view
await interaction.response.send_message("Click the button:", view=MyView())
import discord
from discord import app_commands
from discord.ext import commands
class MyCog(commands.Cog):
"""Description of your cog"""
def __init__(self, bot):
self.bot = bot
@app_commands.command(name='mycommand', description='My command description')
async def my_command(self, interaction: discord.Interaction):
"""My slash command"""
await interaction.response.send_message("Hello from my cog!")
async def setup(bot):
await bot.add_cog(MyCog(bot))
- π₯ Slash Commands: Complete conversion to Discord's modern slash command system
- π¨ Interactive UI: Buttons, modals, and views for better user experience
- β‘ Discord.py 2.5.2: Latest version with all modern features
- ποΈ Improved Architecture: Class-based bot with proper inheritance
- π‘οΈ Better Error Handling: Comprehensive error handling with user-friendly messages
- π Modern Logging: File and console logging with proper formatting
- π Security: Environment variable configuration instead of hardcoded tokens
- π― UI/UX: Beautiful embeds with emojis and consistent styling
- π§Ή Code Quality: Clean, documented, and maintainable code
- βοΈ Auto-sync: Automatic command synchronization on startup
- β Autocomplete: Discord shows available commands as you type
- β Parameter Validation: Automatic type checking and validation
- β
Better Discovery: Users can easily find commands with
/
- β Mobile Friendly: Better experience on mobile devices
- β Rich Descriptions: Commands show helpful descriptions and parameter info
- π Buttons: Interactive buttons for actions
- π Modals: Pop-up forms for user input
- π Select Menus: Dropdown menus for choices
- β±οΈ Timeouts: Automatic cleanup of expired interactions
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-feature
) - Commit your changes (
git commit -am 'Add new feature'
) - Push to the branch (
git push origin feature/new-feature
) - Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you need help with the bot:
- Check the Discord.py documentation
- Review the error logs in
bot.log
- Make sure your
.env
file is properly configured - Ensure the bot has the necessary permissions in your Discord server
- Make sure to invite the bot with both "bot" and "applications.commands" scopes
- Discord.py Documentation
- Discord Developer Portal
- Discord Bot Permissions Calculator
- Discord.py Slash Commands Guide
/embed
Creates an interactive embed creator with buttons for setting title, description, and color.
/poll question:"What's your favorite color?" option1:"Red" option2:"Blue" option3:"Green"
Creates a poll with reaction voting.
/8ball question:"Will it rain tomorrow?"
Ask the magic 8-ball any yes/no question.
Made with β€οΈ using Discord.py 2.5.2 and modern slash commands