wizuem

Build a form where people can apply to be admin, a ticketing system with ticket logs, a welcomer that also says goodbye but it’s called greeting and farewells, a embed maker where people can make embeds by using a command that opens a embed building panel and a bunch of other helpful commands.

Kodari AI
KodariAug 14 at 9:30 pm 1
ServerToolbox
A comprehensive Discord utility bot featuring an admin application form system, a ticketing system with detailed logs, customizable greeting and farewell messages, an interactive embed builder panel, and a suite of helpful moderation and utility commands. Users can apply for admin roles through structured forms, create and manage support tickets with automatic logging, configure welcome/goodbye messages per server, and construct rich embeds visually via command-triggered panels. Additional commands include server info, user info, avatar, clear, kick, ban, and role management tools, all designed for easy setup and user-friendly interaction.

Built the Discord bot project from scratch with:

  • Admin application modal via /apply-admin

  • Staff review workflow via /applications

  • Private ticket system with /ticket-panel

  • Ticket closing and transcript logging

  • Greeting and farewell messages

  • Embed builder via /embed-maker

  • Utility commands: /ping, /serverinfo, /userinfo, /help

  • SQLite persistence for applications and tickets

  • Environment-based token/configuration

  • Permission checks, cooldowns, logging, and error handling

  • Setup documentation in README.md

Run it with:

Shell
cp .env.example .env
pip install -r requirements.txt
python bot.py
wizuem

How do I link my discord bot to this code

Kodari AI
KodariAug 14 at 9:31 pm 1

To connect your Discord bot to the project:

  1. Open the Discord Developer Portal and create or select your application.

  2. Go to Bot → Reset Token, then copy the new token. Keep it private.

  3. In the project folder, create a file named .env.

  4. Set the DISCORD_TOKEN environment variable in that file to your bot token.

  5. Under Bot → Privileged Gateway Intents, enable:

    • Server Members Intent

    • Message Content Intent

  6. Go to OAuth2 → URL Generator:

    • Select the bot and applications.commands scopes.

    • Grant the permissions the bot needs, such as sending messages, managing channels, moderating members, and viewing message history.

  7. Open the generated URL and invite the bot to your server.

  8. Install the dependencies listed in requirements.txt.

  9. Start the project by running bot.py.

When it starts successfully, the bot should appear online and its slash commands should become available. If slash commands do not appear immediately, wait a few minutes or restart Discord.

wizuem

Bot.py

Kodari AI
KodariAug 14 at 9:33 pm 1

bot.py is the bot’s main entry point. To connect and run it:

  1. Place bot.py, .env, and requirements.txt in the same project folder.

  2. Add your Discord bot token to .env as DISCORD_TOKEN=your_token.

  3. Install the dependencies from requirements.txt.

  4. Run bot.py with Python.

  5. Keep the terminal open; closing it will stop the bot.

If you’re asking about a specific problem in bot.py, tell me the error message or what you want the file to do.

wizuem

Can I run the bot from kodari or do I need to copy the code to somewhere else

Kodari AI
KodariAug 14 at 9:37 pm 1

You can build and edit the bot in Kodari, but Kodari generally isn’t where a Discord bot stays running continuously.

To run it, you’ll usually need to copy/download the project to a hosting service or computer, such as:

  • Your own computer

  • Railway

  • Render

  • Replit

  • A VPS

  • Another Python-supporting host

You’ll also need to add the bot token as an environment variable on that service. Never post the token in chat or commit it to your project.

If Kodari provides a dedicated Run, Deploy, or hosting option for your project, you may be able to run it there; otherwise, download the files and host them elsewhere.

Kodari can make mistakes. Review important code before using.
Files
.gitignore
bot.py
config.json
config.py
database.py
README.md
requirements.txt
Code
7 800
bot.py
import io
import logging
import re
from typing import cast

import discord
from discord import app_commands
from discord.ext import commands

from config import Config
from database import Database


logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s %(levelname)s %(name)s: %(message)s",
)
logger = logging.getLogger("kodari-bot")


def is_staff(member: discord.Member, config: Config) -> bool:
    if member.guild_permissions.administrator or member.guild_permissions.manage_guild:
        return True
    return bool(config.admin_role_id and member.get_role(config.admin_role_id))


def truncate(value: str, length: int) -> str:
    return value if len(value) <= length else value[: length - 1] + "…"


class AdminApplicationModal(discord.ui.Modal, title="Admin application"):
    reason = discord.ui.TextInput(
        label="Why should you become an admin?",
        style=discord.TextStyle.paragraph,
        min_length=20,
        max_length=1500,
        required=True,
    )
    experience = discord.ui.TextInput(
        label="Moderation experience",
        style=discord.TextStyle.paragraph,
        min_length=5,
        max_length=1000,
        required=True,
    )

    async def on_submit(self, interaction: discord.Interaction) -> None:
        if interaction.guild is None:
            await interaction.response.send_message(
                "Applications can only be submitted in a server.", ephemeral=True
            )
            return
        bot = cast("KodariBot", interaction.client)
        application_id = await bot.database.create_application(
            interaction.guild.id,
            interaction.user.id,
            str(interaction.user),
            str(self.reason),
            str(self.experience),
        )
        await interaction.response.send_message(
            f"Your admin application was submitted as **#{application_id}**."
            " The staff team will review it.",
            ephemeral=True,
        )


class ApplicationReviewView(discord.ui.View):
    def __init__(self, application_id: int) -> None:
        super().__init__(timeout=None)
        self.application_id = application_id
        accept = discord.ui.Button(
            label="Accept", style=discord.ButtonStyle.success, emoji="✅"
        )
        deny = discord.ui.Button(
            label="Deny", style=discord.ButtonStyle.danger, emoji="❌"
        )
        accept.callback = self.accept_application
        deny.callback = self.deny_application
        self.add_item(accept)
        self.add_item(deny)

    async def accept_application(self, interaction: discord.Interaction) -> None:
        await self.review(interaction, "accepted")

    async def deny_application(self, interaction: discord.Interaction) -> None:
        await self.review(interaction, "denied")

    async def review(self, interaction: discord.Interaction, status: str) -> None:
        if interaction.guild is None or not isinstance(interaction.user, discord.Member):
            await interaction.response.send_message("This action is unavailable here.", ephemeral=True)
            return
        bot = cast("KodariBot", interaction.client)
        if not is_staff(interaction.user, bot.config):
            await interaction.response.send_message(
                "You do not have permission to review applications.", ephemeral=True
            )
            return
        changed = await bot.database.review_application(
            self.application_id, status, interaction.user.id
        )
        if not changed:
            await interaction.response.send_message(
                "This application has already been reviewed.", ephemeral=True
            )
            return
        await interaction.response.send_message(
            f"Application **#{self.application_id}** marked **{status}**.",
            ephemeral=True,
        )
        if interaction.message:
            for item in self.children:
                item.disabled = True
            await interaction.message.edit(view=self)


class TicketPanelView(discord.ui.View):
    def __init__(self) -> None:
        super().__init__(timeout=None)

    @discord.ui.button(
        label="Open a ticket",
        style=discord.ButtonStyle.primary,
        emoji="🎫",
        custom_id="ticket:create",
    )
    async def create_ticket(
        self, interaction: discord.Interaction, button: discord.ui.Button
    ) -> None:
        if interaction.guild is None or not isinstance(interaction.user, discord.Member):
            await interaction.response.send_message("Tickets are server-only.", ephemeral=True)
            return
        bot = cast("KodariBot", interaction.client)
        existing = await bot.database.get_open_ticket(
            interaction.guild.id, interaction.user.id
        )
        if existing:
            channel = interaction.guild.get_channel(existing["channel_id"])
            if channel:
                await interaction.response.send_message(
                    f"You already have an open ticket: {channel.mention}", ephemeral=True
                )
                return

        category = None
        if bot.config.ticket_category_id:
            configured_category = interaction.guild.get_channel(bot.config.ticket_category_id)
            if isinstance(configured_category, discord.CategoryChannel):
                category = configured_category

        bot_member = interaction.guild.me
        overwrites: dict[discord.abc.Snowflake, discord.PermissionOverwrite] = {
            interaction.guild.default_role: discord.PermissionOverwrite(view_channel=False),
            interaction.user: discord.PermissionOverwrite(
                view_channel=True,
                send_messages=True,
                read_message_history=True,
                attach_files=True,
            ),
        }
        if bot_member:
            overwrites[bot_member] = discord.PermissionOverwrite(
                view_channel=True,
                send_messages=True,
                read_message_history=True,
                manage_channels=True,
            )
        if bot.config.admin_role_id:
            role = interaction.guild.get_role(bot.config.admin_role_id)
            if role:
                overwrites[role] = discord.PermissionOverwrite(
                    view_channel=True, send_messages=True, read_message_history=True
                )

        channel_name = "ticket-" + re.sub(r"[^a-z0-9-]", "-", interaction.user.name.lower())[:20]
        try:
            channel = await interaction.guild.create_text_channel(
                channel_name,
                category=category,
                overwrites=overwrites,
                topic=f"Ticket opened by {interaction.user} ({interaction.user.id})",
                reason="Support ticket opened",
            )
            await bot.database.create_ticket(channel.id, interaction.guild.id, interaction.user.id)
        except (discord.Forbidden, discord.HTTPException) as error:
            logger.warning("Could not create ticket: %s", error)
            await interaction.response.send_message(
                "I could not create a ticket. Please contact a moderator.", ephemeral=True
            )
            return

        await channel.send(
            content=f"Welcome {interaction.user.mention}! A staff member will be with you soon.",
            embed=discord.Embed(
                title="Support ticket",
                description="Describe your issue here. Use the button below when the conversation is complete.",
                color=discord.Color.blurple(),
            ),
            view=TicketCloseView(),
        )