blind_.exe

Create a Discord multipurpose bot in Python using discord.py (latest stable version with app_commands / slash commands).

GENERAL REQUIREMENTS

  • Language: Python
  • Library: discord.py
  • Use slash commands only
  • Well-structured, readable, and commented code
  • Use correct intents (members, moderation, message content if required)
  • Include error handling and permission checks
  • Ready to run as a single .py file

EMBED COMMAND Implement a slash command:

/pesend title:<text> description:<text> channel:<#channel>

Behavior:

  • Sends an embed message to the selected channel
  • Embed includes:

- Title from command - Description from command - Footer with bot name - Default embed color (blue or configurable)

  • Only users with Manage Messages permission can use this command
  • Sends an ephemeral confirmation response after success

MODERATION COMMANDS

/mute

  • Temporarily mute (timeout) a user
  • Parameters:

- user - duration in minutes - optional reason

  • Requires Moderate Members permission

/unmute

  • Removes timeout from a user
  • Requires Moderate Members permission

/ban

  • Bans a user
  • Optional reason
  • Requires Ban Members permission

/unban

  • Unbans a user using user ID
  • Requires Ban Members permission

ADDITIONAL DETAILS

  • Log moderation actions in the console
  • Handle missing permissions gracefully
  • Sync slash commands on bot startup
  • Include clear instructions at the top for:

- Installing dependencies - Adding the bot token - Enabling required intents in the Discord Developer Portal

OUTPUT REQUIREMENTS

  • Output only the Python (.py) code
  • No explanations outside code comments
  • Code must be production-ready
Kodari AI
KodariJan 25 at 7:58 am 4,332 (v2)

I’ll create a Discord multipurpose bot with slash commands for moderation and embed management.

DiscordMultiPurposeBot
A comprehensive Discord moderation and utility bot featuring slash commands for embed messages, member timeouts, banning/unbanning, and permission-based access control with ephemeral responses and console logging.
Kodari can make mistakes. Review important code before using.
Files
bot.py
README.md
requirements.txt
Code
3 396
bot.py
import discord
from discord import app_commands
from discord.ext import commands
import os
from dotenv import load_dotenv
from datetime import timedelta
import logging

logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

load_dotenv()

intents = discord.Intents.default()
intents.members = True
intents.message_content = True

bot = commands.Bot(command_prefix='!', intents=intents)

EMBED_COLOR = discord.Color.blue()

@bot.event
async def on_ready():
    logging.info(f'Bot is ready! Logged in as {bot.user}')
    try:
        synced = await bot.tree.sync()
        logging.info(f'Synced {len(synced)} slash command(s)')
    except Exception as e:
        logging.error(f'Failed to sync commands: {e}')

@bot.tree.command(name="pesend", description="Send an embed message to a specified channel")
@app_commands.describe(
    title="The title of the embed",
    description="The description of the embed",
    channel="The channel to send the embed to"
)
@app_commands.checks.has_permissions(manage_messages=True)
async def pesend(
    interaction: discord.Interaction,
    title: str,
    description: str,
    channel: discord.TextChannel
):
    try:
        embed = discord.Embed(
            title=title,
            description=description,
            color=EMBED_COLOR
        )
        embed.set_footer(text=bot.user.name, icon_url=bot.user.avatar.url if bot.user.avatar else None)
        
        await channel.send(embed=embed)
        
        await interaction.response.send_message(
            f"✅ Embed successfully sent to {channel.mention}",
            ephemeral=True
        )
        
        logging.info(f'{interaction.user} sent an embed to #{channel.name} with title: {title}')
        
    except discord.Forbidden:
        await interaction.response.send_message(
            "❌ I don't have permission to send messages in that channel.",
            ephemeral=True
        )
    except Exception as e:
        await interaction.response.send_message(
            f"❌ An error occurred: {str(e)}",
            ephemeral=True
        )
        logging.error(f'Error in pesend command: {e}')

@pesend.error
async def pesend_error(interaction: discord.Interaction, error):
    if isinstance(error, app_commands.errors.MissingPermissions):
        await interaction.response.send_message(
            "❌ You need the 'Manage Messages' permission to use this command.",
            ephemeral=True
        )

@bot.tree.command(name="mute", description="Temporarily mute (timeout) a member")
@app_commands.describe(
    user="The member to mute",
    duration="Duration in minutes",
    reason="Reason for the mute (optional)"
)
@app_commands.checks.has_permissions(moderate_members=True)
async def mute(
    interaction: discord.Interaction,
    user: discord.Member,
    duration: int,
    reason: str = "No reason provided"
):
    try:
        if user.id == interaction.user.id:
            await interaction.response.send_message(
                "❌ You cannot mute yourself.",
                ephemeral=True
            )
            return
        
        if user.guild_permissions.administrator:
            await interaction.response.send_message(
                "❌ You cannot mute an administrator.",
                ephemeral=True
            )
            return
        
        if duration <= 0:
            await interaction.response.send_message(
                "❌ Duration must be a positive number.",
                ephemeral=True
            )
            return
        
        if duration > 40320:
            await interaction.response.send_message(
                "❌ Duration cannot exceed 40320 minutes (28 days).",
                ephemeral=True
            )
            return
        
        timeout_duration = timedelta(minutes=duration)
        await user.timeout(timeout_duration, reason=reason)
        
        await interaction.response.send_message(
            f"✅ {user.mention} has been muted for {duration} minute(s).\nReason: {reason}",
            ephemeral=True
        )
        
        logging.info(f'{interaction.user} muted {user} for {duration} minutes. Reason: {reason}')
        
        try:
            await user.send(f"You have been muted in **{interaction.guild.name}** for {duration} minute(s).\nReason: {reason}")
        except discord.Forbidden:
            pass
        
    except discord.Forbidden:
        await interaction.response.send_message(
            "❌ I don't have permission to timeout this member.",
            ephemeral=True
        )
    except Exception as e:
        await interaction.response.send_message(
            f"❌ An error occurred: {str(e)}",
            ephemeral=True
        )
        logging.error(f'Error in mute command: {e}')

@mute.error
async def mute_error(interaction: discord.Interaction, error):
    if isinstance(error, app_commands.errors.MissingPermissions):
        await interaction.response.send_message(
            "❌ You need the 'Moderate Members' permission to use this command.",
            ephemeral=True
        )

@bot.tree.command(name="unmute", description="Remove timeout from a member")
@app_commands.describe(user="The member to unmute")
@app_commands.checks.has_permissions(moderate_members=True)
async def unmute(interaction: discord.Interaction, user: discord.Member):
    try:
        if user.timed_out_until is None:
            await interaction.response.send_message(
                f"❌ {user.mention} is not currently muted.",
                ephemeral=True
            )
            return
        
        await user.timeout(None)
        
        await interaction.response.send_message(
            f"✅ {user.mention} has been unmuted.",
            ephemeral=True
        )
        
        logging.info(f'{interaction.user} unmuted {user}')
        
        try:
            await user.send(f"You have been unmuted in **{interaction.guild.name}**.")
        except discord.Forbidden:
            pass
        
    except discord.Forbidden:
        await interaction.response.send_message(
            "❌ I don't have permission to remove timeout from this member.",
            ephemeral=True
        )
    except Exception as e:
        await interaction.response.send_message(
            f"❌ An error occurred: {str(e)}",
            ephemeral=True
        )
        logging.error(f'Error in unmute command: {e}')

@unmute.error
async def unmute_error(interaction: discord.Interaction, error):
    if isinstance(error, app_commands.errors.MissingPermissions):
        await interaction.response.send_message(
            "❌ You need the 'Moderate Members' permission to use this command.",
            ephemeral=True