iTokee

Create a discord bot that has custom welcome messages to display when people join, a clock in clock out feature that tracks and create an organized spreadsheet with the data, create custom embedding messages that can be created and sent to certain channels

Kodari AI
KodariJul 13 at 2:40 pm 1
GuildManagerBot
A multi-purpose Discord bot featuring custom welcome messages, attendance tracking with spreadsheet export, and an embed builder. New members receive customizable welcome messages. The clock-in/clock-out system tracks work sessions and exports organized Excel reports. The embed builder allows creating rich embed messages and sending them to any channel with saved templates.

I’ll create a Discord bot with three main cogs, a data manager utility, and supporting files.

I’ll create a comprehensive Discord bot called GuildManagerBot with three main systems: welcome messages, clock in/out tracking, and custom embed builder.

A Discord management bot with three core systems: custom welcome messages with configurable channels and templates, a clock in/out tracking system that logs hours to organized CSV spreadsheets, and an interactive embed builder that creates and sends custom embeds to any channel. All data is persisted locally using JSON and CSV files for easy export and review.
A Discord bot for guild/server management featuring three core systems: customizable welcome messages triggered on member join, a clock in/out attendance tracking system that logs sessions and exports data to organized CSV spreadsheets, and an interactive embed builder for creating, saving, and sending custom embedded messages to any channel. All data persists via JSON files.

All files are created. Here’s a summary of the GuildManagerBot:

Project Structure

Plain Text
GuildManagerBot/
├── main.py                    # Bot entry point, error handling, help
├── .env                       # Discord token
├── requirements.txt           # Dependencies
├── cogs/
│   ├── __init__.py
│   ├── welcome.py             # Welcome message system
│   ├── clock_cog.py           # Clock in/out tracking
│   └── embed_builder.py       # Custom embed builder
├── utils/
│   ├── __init__.py
│   └── data_manager.py        # JSON persistence utility
└── data/
    └── .gitkeep               # Runtime data stored here

Features

👋 Welcome System (!welcome)

  • Set a designated welcome channel

  • Custom text messages with placeholders: {mention}, {username}, {server}, {member_count}

  • Or use a saved embed as the welcome message

  • Enable/disable toggle, test command, status display

🕐 Clock In/Out Tracking (!clock)

  • !clock in [note] / !clock out [note] — track work sessions

  • !clock status — check if you’re clocked in

  • !clock history / !clock today — view session history

  • !clock export — download all data as a CSV spreadsheet (organized with User ID, Date, Clock In, Clock Out, Duration, Notes)

  • !clock export_user @user — export a single user’s data

  • !clock report — admin summary of all users

📦 Custom Embed Builder (!embed)

  • Interactive session-based builder with commands: !embed title, !embed desc, !embed color, !embed field, !embed footer, !embed thumbnail, !embed image, !embed author

  • !embed save <name> — save for later use

  • !embed list — browse saved embeds

  • !embed send <#channel> <name> — send to any channel

  • !embed preview <name> — preview before sending

  • !embed quick Title | Description — one-liner embeds

Setup

  1. Add your bot token to .env: DISCORD_TOKEN=your_token_here

  2. Install dependencies: pip install -r requirements.txt

  3. Run: python main.py

Kodari can make mistakes. Review important code before using.
Files
cogs
data
utils
requirements.txt
Code
7 988
cogs/welcome.py
import discord
from discord.ext import commands
import datetime
from utils.data_manager import DataManager


class WelcomeCog(commands.Cog):
    """Custom welcome messages when members join the server."""

    def __init__(self, bot: commands.Bot):
        self.bot = bot
        self.config_file = "welcome_config.json"

    @commands.Cog.listener()
    async def on_member_join(self, member: discord.Member):
        """Triggered when a new member joins the server."""
        config = DataManager.load_json(self.config_file, {})
        guild_id = str(member.guild.id)
        guild_config = config.get(guild_id, {})

        if not guild_config.get("enabled", False):
            return

        channel_id = guild_config.get("channel_id")
        if not channel_id:
            return

        channel = member.guild.get_channel(channel_id)
        if not channel:
            return

        message_template = guild_config.get(
            "message",
            "Welcome {mention} to {server}! 🎉"
        )

        custom_embed_enabled = guild_config.get("use_embed", False)
        embed_name = guild_config.get("embed_name")

        if custom_embed_enabled and embed_name:
            embeds_data = DataManager.load_json("saved_embeds.json", {})
            embed_data = embeds_data.get(embed_name)
            if embed_data:
                embed = self._build_welcome_embed(embed_data, member)
                await channel.send(content=guild_config.get("embed_message", ""), embed=embed)
                return

        welcome_message = (
            message_template
            .replace("{mention}", member.mention)
            .replace("{username}", member.name)
            .replace("{display_name}", member.display_name)
            .replace("{server}", member.guild.name)
            .replace("{member_count}", str(member.guild.member_count))
        )
        await channel.send(welcome_message)

    @staticmethod
    def _build_welcome_embed(embed_data: dict, member: discord.Member) -> discord.Embed:
        """Build a welcome embed from saved embed data, templating member info."""
        title = embed_data.get("title", "Welcome!").replace("{username}", member.name).replace("{display_name}", member.display_name).replace("{mention}", member.mention)
        description = embed_data.get("description", "").replace("{username}", member.name).replace("{display_name}", member.display_name).replace("{mention}", member.mention).replace("{server}", member.guild.name).replace("{member_count}", str(member.guild.member_count))
        embed = discord.Embed(
            title=title,
            description=description,
            color=embed_data.get("color", 0x5865F2)
        )
        for field in embed_data.get("fields", []):
            f_name = field.get("name", "").replace("{username}", member.name)
            f_value = field.get("value", "").replace("{username}", member.name)
            embed.add_field(name=f_name, value=f_value, inline=field.get("inline", False))
        if embed_data.get("footer"):
            embed.set_footer(text=embed_data["footer"])
        if embed_data.get("thumbnail"):
            embed.set_thumbnail(url=embed_data["thumbnail"])
        if embed_data.get("image"):
            embed.set_image(url=embed_data["image"])
        if embed_data.get("author_name"):
            embed.set_author(name=embed_data["author_name"], icon_url=embed_data.get("author_icon"))
        return embed

    @commands.group(name="welcome", invoke_without_command=True)
    @commands.has_permissions(administrator=True)
    async def welcome(self, ctx: commands.Context):
        """Manage welcome message settings."""
        embed = discord.Embed(
            title="👋 Welcome System Commands",
            color=discord.Color.green()
        )
        embed.add_field(name="!welcome channel <#channel>", value="Set the welcome channel", inline=False)
        embed.add_field(name="!welcome message <text>", value="Set the welcome message. Use {mention}, {username}, {display_name}, {server}, {member_count}", inline=False)
        embed.add_field(name="!welcome embed <embed_name>", value="Use a saved embed as welcome (overrides message)", inline=False)
        embed.add_field(name="!welcome text", value="Switch back to text-only welcome", inline=False)
        embed.add_field(name="!welcome enable", value="Enable welcome messages", inline=False)
        embed.add_field(name="!welcome disable", value="Disable welcome messages", inline=False)
        embed.add_field(name="!welcome test", value="Test the welcome message", inline=False)
        embed.add_field(name="!welcome status", value="Show current welcome settings", inline=False)
        await ctx.send(embed=embed)

    @welcome.command(name="channel")
    async def welcome_channel(self, ctx: commands.Context, channel: discord.TextChannel):
        """Set the welcome channel."""
        config = DataManager.load_json(self.config_file, {})
        guild_id = str(ctx.guild.id)
        if guild_id not in config:
            config[guild_id] = {"enabled": False}
        config[guild_id]["channel_id"] = channel.id
        DataManager.save_json(self.config_file, config)
        await ctx.send(f"✅ Welcome channel set to {channel.mention}.")

    @welcome.command(name="message")
    async def welcome_message(self, ctx: commands.Context, *, message: str):
        """Set the welcome message text."""
        config = DataManager.load_json(self.config_file, {})
        guild_id = str(ctx.guild.id)
        if guild_id not in config:
            config[guild_id] = {"enabled": False}
        config[guild_id]["message"] = message
        config[guild_id]["use_embed"] = False
        DataManager.save_json(self.config_file, config)
        await ctx.send(f"✅ Welcome message set.\nPreview: {message.replace('{mention}', ctx.author.mention).replace('{username}', ctx.author.name).replace('{display_name}', ctx.author.display_name).replace('{server}', ctx.guild.name).replace('{member_count}', str(ctx.guild.member_count))}")

    @welcome.command(name="embed")
    async def welcome_embed(self, ctx: commands.Context, embed_name: str):
        """Use a saved embed as the welcome message."""
        embeds = DataManager.load_json("saved_embeds.json", {})
        if embed_name not in embeds:
            saved = list(embeds.keys())
            await ctx.send(f"❌ No saved embed named **{embed_name}**. Available: {', '.join(saved) if saved else 'None'}")
            return
        config = DataManager.load_json(self.config_file, {})
        guild_id = str(ctx.guild.id)
        if guild_id not in config:
            config[guild_id] = {"enabled": False}
        config[guild_id]["use_embed"] = True
        config[guild_id]["embed_name"] = embed_name
        config[guild_id]["embed_message"] = ""
        DataManager.save_json(self.config_file, config)
        await ctx.send(f"✅ Welcome will now use the **{embed_name}** embed. Use `!welcome embed_message <text>` to add a text message above it.")

    @welcome.command(name="embed_message")
    async def welcome_embed_message(self, ctx: commands.Context, *, text: str):
        """Set a text message to accompany the welcome embed."""
        config = DataManager.load_json(self.config_file, {})
        guild_id = str(ctx.guild.id)
        if guild_id not in config:
            await ctx.send("❌ Configure welcome first with `!welcome channel`.")
            return
        config[guild_id]["embed_message"] = text
        DataManager.save_json(self.config_file, config)
        await ctx.send("✅ Embed message text set.")

    @welcome.command(name="text")
    async def welcome_text(self, ctx: commands.Context):
        """Switch back to text-only welcome message."""
        config = DataManager.load_json(self.config_file, {})
        guild_id = str(ctx.guild.id)
        if guild_id not in config:
            await ctx.send("❌ No welcome config yet.")
            return
        config[guild_id]["use_embed"] = False
        DataManager.save_json(self.config_file, config)
        await ctx.send("✅ Switched to text-only welcome message.")

    @welcome.command(name="enable")
    async def welcome_enable(self, ctx: commands.Context):
        """Enable welcome messages."""
        config = DataManager.load_json(self.config_file, {})
        guild_id = str(ctx.guild.id)
        if guild_id not in config or not config[guild_id].get("channel_id"):
            await ctx.send("❌ Set a welcome channel first with `!welcome channel #channel`.")
            return
        config[guild_id]["enabled"] = True
        DataManager.save_json(self.config_file, config)
        await ctx.send("✅ Welcome messages enabled.")

    @welcome.command(name="disable")
    async def welcome_disable(self, ctx: commands.Context):
        """Disable welcome messages."""
        config = DataManager.load_json(self.config_file, {})
        guild_id = str(ctx.guild.id)
        if guild_id not in config:
            await ctx.send("No welcome config to disable.")
            return
        config[guild_id]["enabled"] = False
        DataManager.save_json(self.config_file, config)
        await ctx.send("✅ Welcome messages disabled.")

    @welcome.command(name="test")
    async def welcome_test(self, ctx: commands.Context):
        """Test the welcome message as if you just joined."""
        config = DataManager.load_json(self.config_file, {})
        guild_id = str(ctx.guild.id)
        guild_config = config.get(guild_id, {})
        if not guild_config.get("channel_id"):
            await ctx.send("❌ No welcome channel configured.")
            return
        channel = ctx.guild.get_channel(guild_config["channel_id"])
        if not channel:
            await ctx.send("❌ Configured welcome channel no longer exists.")