darro.1

make me a discord middleman bot

Kodari AI
KodariOct 7 at 12:56 am 1
DiscordMiddlemanBot
A Discord bot that acts as a middleman for secure peer-to-peer trades. Users initiate trades via slash commands, the bot escrows both parties' items or currency, verifies terms, and facilitates the exchange. Features include trade creation, offer confirmation, escrow holding, automatic release upon mutual agreement, dispute logging, and trade history tracking. Built with discord.py, it uses slash commands, ephemeral responses for privacy, and a SQLite database for persistent trade records.
  1. Create a slash-command bot that opens private deal channels for the buyer and seller.

  2. Add agreement, delivery, and receipt-confirmation buttons, plus moderator setup and resolution.

  3. Persist deal state across restarts and include the required environment and dependency files.

Created a discord.py middleman bot with private deal channels, persistent deal status, and buttons for both parties to agree, mark delivery, and confirm receipt. Moderators can configure a staff role with /middleman_role and resolve deals with /middleman_resolve.

Replace the placeholder in .env with your bot token, then install dependencies from requirements.txt. The bot needs Manage Channels to create private deal channels. It uses no privileged intents.

It coordinates trade confirmations but does not hold money or guarantee a trade.

darro.1

make more middleman commands

Kodari AI
KodariOct 7 at 1:01 am 1
  1. Add a private /middleman_status command for deal participants and staff.

  2. Add staff-only /middleman_list for open deals in the server.

  3. Add /middleman_ping to notify the other party in the deal channel.

Added three commands:

  • /middleman_status — privately shows deal status to participants and staff.

  • /middleman_list — privately lists up to 20 open deals for server staff.

  • /middleman_ping — reminds the other party, limited to one ping per minute.

darro.1

make 15 more middleman commands

Kodari AI
KodariOct 7 at 1:04 am 1
  1. Check the existing deal model and command names so the additions fit without conflicts.

  2. Add 15 practical slash commands for participants and staff, reusing the bot’s current permissions and persistence.

  3. Keep the commands focused on coordinating trades; the bot won’t claim to escrow or guarantee assets.

Added 15 commands:

  • Deal actions: /middleman_agree, /middleman_deliver, /middleman_received, /middleman_dispute, /middleman_update, /middleman_reopen

  • Channel management: /middleman_add_member, /middleman_remove_member, /middleman_rename, /middleman_archive, /middleman_unarchive

  • Tracking and help: /middleman_mine, /middleman_stats, /middleman_export, /middleman_guide

Staff-only actions require Manage Server or the configured staff role. The bot records and coordinates trade confirmations, but doesn’t hold assets or guarantee trades.

darro.1

make a middleman ticket system

Kodari AI
KodariOct 7 at 1:08 am 1

Plan:

  1. Add a persistent ticket panel and private ticket creation flow without changing existing deal commands.

  2. Add ticket controls to claim, add a counterparty, and close the ticket with permission checks.

  3. Persist tickets in SQLite so controls keep working after restarts.

Added a persistent ticket system:

  • /middleman_ticket_panel posts the button members use to open a private ticket.

  • Ticket buttons let staff claim a ticket and let its owner or staff close it.

  • /middleman_ticket_add gives the other trade participant access.

  • /middleman_ticket_reopen lets staff reopen a closed ticket.

  • Ticket records persist in SQLite, and the controls work after restarts.

The panel command requires Manage Server. The bot needs Manage Channels to create tickets. Once the trade details are ready, staff can use the existing /middleman command to create the deal channel. The bot coordinates confirmations; it does not hold or guarantee assets.

darro.1

make 100 more commands for a middleman bot

Kodari AI
KodariOct 7 at 1:31 am 1

Plan:

  1. Add four slash-command groups with 25 subcommands each to stay within Discord’s per-group limit.

  2. Make deal and ticket shortcuts read or update persisted records with participant/staff checks.

  3. Add staff reports and trade-safety reference commands; keep the existing commands intact.

Added 100 slash-command subcommands, organized into four menus of 25 each:

  • /deals … — deal status, terms, participant details, and agreement/delivery/receipt actions.

  • /tickets … — ticket status and controls, including claim, close, and reopen.

  • /staff … — deal and ticket queues, server stats, and setup/permission information.

  • /safety … — trade-safety guidance for buyers, sellers, payments, evidence, and disputes.

Use the grouped format, such as /deals status or /safety scam_prevention. Commands that change deal or ticket state enforce participant or staff checks. The bot coordinates trade confirmations; it does not hold or guarantee assets.

darro.1

how to add this bot to my server>

Kodari AI
KodariOct 7 at 1:46 am 1
  1. Create the Discord application: Go to the Discord Developer Portal, create an application, open Bot, and add a bot. Copy its token and put it in your project’s .env as DISCORD_TOKEN=your_token_here. Keep the token private.

  2. Create an invite link: In OAuth2 → URL Generator, select the bot and applications.commands scopes. Select permissions the bot needs, including Manage Channels, View Channels, Send Messages, Embed Links, and Read Message History. Copy the generated URL.

  3. Invite it: Open that URL, choose your server, and authorize it. You need permission to manage that server.

  4. Run the bot: Start the project and make sure it stays running. The slash commands will be available once Discord has synced them; global commands can take a little time to appear.

If you use the ticket system, check that the bot’s role can access the category where tickets should be created.

darro.1

make a command where i can open a ticket and call it MM deals with the recipent that made the ticket

Kodari AI
KodariOct 7 at 1:53 am 1
  1. Add /middleman_ticket so a member can open their own private ticket directly.

  2. Name the channel mm-deals-<username> and show the opener as the ticket owner, using the existing ticket controls and database.

Added /middleman_ticket. It opens a private channel named mm-deals-<your-username>, gives access to you and configured staff, and includes the existing ticket controls. Use /middleman_ticket in your server.

darro.1

make a middleman tos channel when a ticket is created put some mm rules tht are proofesional

Kodari AI
KodariOct 7 at 1:56 am 1
  1. Create one read-only middleman-tos channel per server when the first ticket is opened.

  2. Post professional trade rules there and include the rules in each new private ticket.

Added a read-only #middleman-tos channel, created when the first ticket is opened. It contains professional trade, verification, privacy, dispute, and service-limit rules; the rules are also included in every new ticket. The terms clarify that the bot does not hold or guarantee money or items.

darro.1

remove all of the unnesscary commands

Kodari AI
KodariOct 7 at 10:42 pm 1

Plan:

  1. Remove the 100 generic grouped subcommands that clutter the command menu.

  2. Keep the core deal, ticket, and staff commands needed to run the middleman workflow.

Removed the 100 generic grouped subcommands from the slash-command menu. The core deal, ticket, and staff commands remain.

darro.1

can you remove aiobot.net i accidently added it to my server and it put alot of non middleman commands

Kodari AI
KodariOct 7 at 10:44 pm 1

I can’t remove a bot from your Discord server directly. To remove aiobot.net, open Server Settings → Members, find aiobot.net, and choose Kick. If it appears under Server Settings → Integrations → Bots and Apps, you can remove it there instead. You’ll need permission to manage the server.

That removes its commands from your server; changing this project’s code can’t remove another bot’s commands.

darro.1

remove every single command in the bot and add it again

Kodari AI
KodariOct 7 at 10:52 pm 1
  1. Preserve the current middleman slash commands, but clear and re-register this bot’s global command list once on startup.

  2. Leave commands from other Discord apps untouched; only that app’s server admins can remove them.

Added a one-time command reset on the bot’s next startup: it clears this app’s global slash commands, then republishes the middleman commands currently in the project. Restart the bot to apply it.

This only resets your bot’s commands. It can’t remove aiobot.net commands; remove that app from the server to clear its commands.

darro.1

but how

Kodari AI
KodariOct 7 at 10:53 pm 1

Open this bot’s project in Kodari, stop the running bot, then start it again. The reset runs on startup; wait until the logs show KODARI_READY. Global slash-command changes may take a little while to show in Discord.

This only resets your bot’s commands—it won’t remove aiobot.net’s commands. Remove that app from your server separately if they’re still there.

Kodari can make mistakes. Review important code before using.
Files
bot.py
requirements.txt
Code
2 1,406
bot.py
import logging
import io
import os
import sqlite3
from contextlib import contextmanager
from pathlib import Path

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


load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")
DATABASE_PATH = Path(__file__).with_name("middleman.sqlite3")
FINAL_STATUSES = {"completed", "resolved_completed", "resolved_cancelled"}

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


@contextmanager
def database():
    connection = sqlite3.connect(DATABASE_PATH)
    connection.row_factory = sqlite3.Row
    try:
        yield connection
        connection.commit()
    except Exception:
        connection.rollback()
        raise
    finally:
        connection.close()


def initialize_database():
    with database() as connection:
        connection.execute(
            """CREATE TABLE IF NOT EXISTS deals (
                channel_id INTEGER PRIMARY KEY,
                guild_id INTEGER NOT NULL,
                buyer_id INTEGER NOT NULL,
                seller_id INTEGER NOT NULL,
                details TEXT NOT NULL,
                status TEXT NOT NULL,
                buyer_accepted INTEGER NOT NULL DEFAULT 0,
                seller_accepted INTEGER NOT NULL DEFAULT 0,
                message_id INTEGER,
                resolution_note TEXT NOT NULL DEFAULT ''
            )"""
        )
        connection.execute(
            """CREATE TABLE IF NOT EXISTS guild_settings (
                guild_id INTEGER PRIMARY KEY,
                staff_role_id INTEGER NOT NULL
            )"""
        )
        connection.execute(
            """CREATE TABLE IF NOT EXISTS tickets (
                channel_id INTEGER PRIMARY KEY,
                guild_id INTEGER NOT NULL,
                owner_id INTEGER NOT NULL,
                status TEXT NOT NULL DEFAULT 'open',
                claimed_by INTEGER
            )"""
        )
        connection.execute(
            """CREATE TABLE IF NOT EXISTS bot_metadata (
                key TEXT PRIMARY KEY,
                value TEXT NOT NULL
            )"""
        )


def create_deal(guild_id, channel_id, buyer_id, seller_id, details):
    with database() as connection:
        connection.execute(
            "INSERT INTO deals (guild_id, channel_id, buyer_id, seller_id, details, status) "
            "VALUES (?, ?, ?, ?, ?, 'awaiting_agreement')",
            (guild_id, channel_id, buyer_id, seller_id, details),
        )


def get_deal(channel_id):
    with database() as connection:
        row = connection.execute("SELECT * FROM deals WHERE channel_id = ?", (channel_id,)).fetchone()
        return dict(row) if row else None


def create_ticket(guild_id, channel_id, owner_id):
    with database() as connection:
        connection.execute(
            "INSERT INTO tickets (guild_id, channel_id, owner_id, status) VALUES (?, ?, ?, 'open')",
            (guild_id, channel_id, owner_id),
        )


def get_ticket(channel_id):
    with database() as connection:
        row = connection.execute("SELECT * FROM tickets WHERE channel_id = ?", (channel_id,)).fetchone()
        return dict(row) if row else None


def set_ticket_claim(channel_id, user_id):
    with database() as connection:
        connection.execute(
            "UPDATE tickets SET claimed_by = ? WHERE channel_id = ? AND status = 'open' AND claimed_by IS NULL",
            (user_id, channel_id),
        )
        row = connection.execute("SELECT * FROM tickets WHERE channel_id = ?", (channel_id,)).fetchone()
        return dict(row) if row else None


def set_ticket_status(channel_id, status):
    with database() as connection:
        connection.execute("UPDATE tickets SET status = ? WHERE channel_id = ?", (status, channel_id))
        row = connection.execute("SELECT * FROM tickets WHERE channel_id = ?", (channel_id,)).fetchone()
        return dict(row) if row else None


def get_open_deals(guild_id):
    with database() as connection:
        rows = connection.execute(
            "SELECT * FROM deals WHERE guild_id = ? AND status NOT IN (?, ?, ?) ORDER BY channel_id DESC LIMIT 20",
            (guild_id, *FINAL_STATUSES),
        ).fetchall()
        return [dict(row) for row in rows]


def get_member_deals(guild_id, user_id, include_closed):
    with database() as connection:
        if include_closed:
            rows = connection.execute(
                "SELECT * FROM deals WHERE guild_id = ? AND (buyer_id = ? OR seller_id = ?) "
                "ORDER BY channel_id DESC LIMIT 20",
                (guild_id, user_id, user_id),
            ).fetchall()
        else:
            rows = connection.execute(
                "SELECT * FROM deals WHERE guild_id = ? AND (buyer_id = ? OR seller_id = ?) "
                "AND status NOT IN (?, ?, ?) ORDER BY channel_id DESC LIMIT 20",
                (guild_id, user_id, user_id, *FINAL_STATUSES),
            ).fetchall()
        return [dict(row) for row in rows]


def get_deal_counts(guild_id):
    with database() as connection:
        rows = connection.execute(
            "SELECT status, COUNT(*) AS count FROM deals WHERE guild_id = ? GROUP BY status",
            (guild_id,),
        ).fetchall()
        return {row["status"]: row["count"] for row in rows}


def update_deal_details(channel_id, details):
    with database() as connection:
        connection.execute(
            "UPDATE deals SET details = ?, status = 'awaiting_agreement', "
            "buyer_accepted = 0, seller_accepted = 0, resolution_note = '' WHERE channel_id = ?",
            (details, channel_id),
        )
        row = connection.execute("SELECT * FROM deals WHERE channel_id = ?", (channel_id,)).fetchone()
        return dict(row) if row else None


def set_message_id(channel_id, message_id):
    with database() as connection:
        connection.execute("UPDATE deals SET message_id = ? WHERE channel_id = ?", (message_id, channel_id))


def record_acceptance(channel_id, user_id):
    with database() as connection:
        deal = connection.execute("SELECT * FROM deals WHERE channel_id = ?", (channel_id,)).fetchone()
        if not deal:
            return None
        column = "buyer_accepted" if user_id == deal["buyer_id"] else "seller_accepted"
        connection.execute(f"UPDATE deals SET {column} = 1 WHERE channel_id = ?", (channel_id,))
        deal = connection.execute("SELECT * FROM deals WHERE channel_id = ?", (channel_id,)).fetchone()
        if deal["buyer_accepted"] and deal["seller_accepted"]:
            connection.execute("UPDATE deals SET status = 'active' WHERE channel_id = ?", (channel_id,))
            deal = connection.execute("SELECT * FROM deals WHERE channel_id = ?", (channel_id,)).fetchone()
        return dict(deal)


def set_deal_status(channel_id, status, note=""):
    with database() as connection:
        connection.execute(
            "UPDATE deals SET status = ?, resolution_note = ? WHERE channel_id = ?",
            (status, note, channel_id),
        )
        row = connection.execute("SELECT * FROM deals WHERE channel_id = ?", (channel_id,)).fetchone()
        return dict(row) if row else None


def set_staff_role(guild_id, role_id):
    with database() as connection:
        connection.execute(
            "INSERT INTO guild_settings (guild_id, staff_role_id) VALUES (?, ?) "