cookiedough09836

Wake the bot up so its online and activate the commands

Kodari AI
KodariAug 18 at 6:24 pm 1
DiscordBotWakeUp
A Discord bot that wakes up and activates its commands when mentioned or when a specific trigger word is used. The bot monitors for activation signals, transitions from idle to active state, and enables its full command suite once activated. It includes a wake-up command, status indicators, and automatic activation on server join.

[Generation stopped]

cookiedough09836

create a command /wakeupbot which wakes up the bot and activates it comannd. Also add setup to set up the tickets

Kodari AI
KodariAug 18 at 6:26 pm 1
TicketWakeBot
A Discord bot that provides a /wakeupbot command to activate the bot and enable its functionality. Includes a comprehensive ticket setup system allowing administrators to configure ticket channels, categories, roles, and welcome messages. The bot manages ticket creation, assignment, and closure workflows with persistent storage for configuration and active tickets.
  1. Create a discord.py bot entry point with /wakeupbot, guild activation, command syncing, and startup logging.

  2. Add ticket setup and ticket lifecycle commands with persistent open/close buttons and permission-aware private channels.

  3. Add environment/dependency files and setup instructions without storing a real token.

Created the Discord bot project with:

  • bot.py β€” bot startup, online logging, slash-command syncing, /wakeupbot, and ticket commands.

  • /wakeupbot β€” administrator-only command that activates commands per server.

  • /ticketsetup β€” creates a ticket panel with optional category and support role.

  • /ticket and /ticketclose β€” private ticket creation and closing.

  • Persistent configuration in bot_data.json.

  • .env.example for DISCORD_TOKEN.

  • requirements.txt, .gitignore, and README.md setup instructions.

Start it with:

Shell
cp .env.example .env
# Add your Discord token to .env
pip install -r requirements.txt
python bot.py

Then run /wakeupbot in your server, followed by /ticketsetup.

cookiedough09836
πŸ“Ž 1 file 1,296 chars
πŸ“„
pasted-code-1787078075263.txt
txt 18 lines
β–Ά
## Ordering Tool

### Ticket System
In a channel, there should be a message where people can press a button to open a ticket. In the ticket, they can send their order. When it’s made, there should be like a welcome message saying stuff like β€œPlease send your order and staff will reply soon.” The person ordering should send in their order and a staff member can press a button on the welcome order message to claim the order. They should use a give command to give the item. Then, the staff can close the ticket using the order complete button.

### Give Command

There should be a command to give the food. Once /give is used they need to put the user and the food. Please note that we might consider weekly menus, but if you don’t want that we can make it monthly. 

### Shift Slash Commands

There should be **TWO** shift commands. One called Startshift, which announces that a shift is happening. Endshift announces that it’s ended. It should send it to a specific channel, not just the channel the command is used in. 

### Levels

Staff should have some levels. Every time they level it’s send to a specific channel. Reason I want this is so corporates can track their levels, activity so they can look out for promotions.

**Note: More is to be added that I might want!**
Kodari AI
KodariAug 18 at 6:36 pm 1
  1. Expand the ticket workflow into an order workflow with open, claim, give, and completion controls.

  2. Add /give with staff permissions and order/food recording.

  3. Add /startshift and /endshift announcements to a configured channel.

  4. Add staff levels, activity tracking, and promotion notifications with persistent storage.

  5. Update configuration and setup documentation for the new channels, roles, and menu period.

Implemented the ordering system in bot.py:

  • Added private order tickets with a welcome message.

  • Added Claim order and Order complete buttons.

  • Added /give user food for staff to record food deliveries.

  • Added /startshift and /endshift announcements to a configured channel.

  • Added staff activity tracking and /stafflevel.

  • Added automatic staff level-up announcements to a configured channel.

  • Extended /ticketsetup with:

    • Order category

    • Support role

    • Shift announcement channel

    • Staff levels channel

    • Weekly or monthly menu period

  • Replaced the exposed-looking example token with a safe placeholder.

  • Updated README.md setup and command documentation.

Start the bot, then run:

Plain Text
/wakeupbot
/ticketsetup

Use /ticketsetup again later to update the configured channels or menu period.

cookiedough09836

They havent upfated. Restart the bot and update the command list

Kodari AI
KodariAug 18 at 6:41 pm 1

[Generation stopped]

cookiedough09836

They havent upfated. Restart the bot and update the command list

Kodari AI
KodariAug 18 at 6:43 pm 1
  1. Make slash-command syncing immediate for a configured server, while retaining global sync fallback.

  2. Update the environment example and startup instructions with the guild ID setting.

  3. Provide the exact restart command; the bot process cannot be restarted from this read-only project workspace.

Kodari can make mistakes. Review important code before using.
Files
.gitignore
bot.py
README.md
requirements.txt
Code
4 768
bot.py
from __future__ import annotations

import asyncio
import json
import logging
import os
import re
from datetime import datetime, timezone
from pathlib import Path
from typing import Any

import discord
from discord import app_commands
from discord.ext import commands
from dotenv import load_dotenv


load_dotenv()

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

DATA_FILE = Path(os.getenv("BOT_DATA_FILE", "bot_data.json"))
LEVEL_INTERVAL = 5


class BotData:
    def __init__(self, path: Path) -> None:
        self.path = path
        self._data: dict[str, Any] = {"guilds": {}}
        self._lock = asyncio.Lock()
        self._load()

    def _load(self) -> None:
        if not self.path.exists():
            return
        try:
            loaded = json.loads(self.path.read_text(encoding="utf-8"))
            if isinstance(loaded, dict) and isinstance(loaded.get("guilds"), dict):
                self._data = loaded
        except (OSError, json.JSONDecodeError):
            logger.warning("Could not load %s; starting with empty bot data", self.path)

    async def save(self) -> None:
        async with self._lock:
            self.path.parent.mkdir(parents=True, exist_ok=True)
            temporary = self.path.with_suffix(".tmp")
            temporary.write_text(
                json.dumps(self._data, indent=2, sort_keys=True),
                encoding="utf-8",
            )
            temporary.replace(self.path)

    def guild(self, guild_id: int) -> dict[str, Any]:
        guilds = self._data.setdefault("guilds", {})
        settings = guilds.setdefault(str(guild_id), {})
        settings.setdefault("orders", {})
        settings.setdefault("staff", {})
        settings.setdefault("give_history", [])
        return settings


data = BotData(DATA_FILE)


def clean_channel_name(name: str) -> str:
    result = re.sub(r"[^a-z0-9-]+", "-", name.lower()).strip("-")
    return (result or "user")[:18]


def is_active(guild_id: int) -> bool:
    return bool(data.guild(guild_id).get("active", False))


async def require_active(interaction: discord.Interaction) -> bool:
    if interaction.guild is None:
        await interaction.response.send_message(
            "This command can only be used in a server.", ephemeral=True
        )
        return False
    if not is_active(interaction.guild.id):
        await interaction.response.send_message(
            "The bot is asleep here. An administrator must run `/wakeupbot` first.",
            ephemeral=True,
        )
        return False
    return True


def ticket_owner(channel: discord.abc.GuildChannel) -> int | None:
    topic = getattr(channel, "topic", None) or ""
    match = re.fullmatch(r"ticket-owner:(\d+)", topic)
    return int(match.group(1)) if match else None


async def find_open_ticket(
    guild: discord.Guild, user_id: int
) -> discord.TextChannel | None:
    for channel in guild.text_channels:
        if ticket_owner(channel) == user_id:
            return channel
    return None


def is_staff(member: discord.Member, settings: dict[str, Any]) -> bool:
    if member.guild_permissions.administrator or member.guild_permissions.manage_channels:
        return True
    role_id = settings.get("support_role_id")
    return bool(role_id and any(role.id == int(role_id) for role in member.roles))


async def track_staff_activity(
    guild: discord.Guild, member: discord.Member, action: str
) -> None:
    settings = data.guild(guild.id)
    staff = settings["staff"].setdefault(
        str(member.id), {"activity": 0, "level": 1, "last_action": ""}
    )
    old_level = int(staff.get("level", 1))
    staff["activity"] = int(staff.get("activity", 0)) + 1
    staff["level"] = max(1, staff["activity"] // LEVEL_INTERVAL + 1)
    staff["last_action"] = action
    await data.save()

    if staff["level"] <= old_level:
        return
    level_channel_id = settings.get("levels_channel_id")
    level_channel = guild.get_channel(int(level_channel_id)) if level_channel_id else None
    if not isinstance(level_channel, discord.TextChannel):
        return
    try:
        await level_channel.send(
            f"πŸŽ‰ {member.mention} reached **Staff Level {staff['level']}** "
            f"after {staff['activity']} tracked actions."
        )
    except (discord.Forbidden, discord.HTTPException):
        logger.warning("Could not announce a staff level in guild %s", guild.id)


def order_for_channel(
    guild: discord.Guild, channel: discord.TextChannel
) -> dict[str, Any] | None:
    return data.guild(guild.id)["orders"].get(str(channel.id))


async def create_ticket(interaction: discord.Interaction) -> None:
    guild = interaction.guild
    if guild is None or not await require_active(interaction):
        return

    existing = await find_open_ticket(guild, interaction.user.id)
    if existing is not None:
        await interaction.response.send_message(
            f"You already have an open order: {existing.mention}", ephemeral=True
        )
        return

    settings = data.guild(guild.id)
    if not settings.get("ticket_panel_channel_id"):
        await interaction.response.send_message(
            "Orders are not configured yet. An administrator must run `/ticketsetup`.",
            ephemeral=True,
        )
        return

    category = None
    category_id = settings.get("category_id")
    if category_id:
        category = guild.get_channel(int(category_id))
        if not isinstance(category, discord.CategoryChannel):
            category = None

    bot_member = guild.me
    if bot_member is None:
        await interaction.response.send_message(
            "I could not resolve my server permissions. Please try again.",
            ephemeral=True,
        )
        return

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

    support_role_id = settings.get("support_role_id")