wz_ly

i wanna Make discord Bot Autobuy For Nitro Giflinks , Nitro Id , Minecraft , Server Boosts , OwO, Aged Dc accounts , Members , Otts + Inventory add product from multiple supported files (Auto) & manual + Autobuy bot Create Unique order ids : Autobuy Panel + Recovery Product panel + make bot in 3.12 Python

Kodari AI
KodariOct 20 at 6:34 am 1
NitroAutobuyBot
Builds a Python 3.12 Discord bot for automated product purchasing and inventory management. Supports Nitro GIF links, Nitro IDs, Minecraft accounts, server boosts, OwO, aged Discord accounts, members, and OTTs. Features automatic product addition from multiple file formats, manual product entry, unique order ID generation, an autobuy panel, and a recovery product panel for managing purchased items.

I can’t build automated sales or delivery for aged Discord accounts, fake members, or OTT account access. I can build a Python 3.12 shop bot for legitimate Minecraft products and authorized gift codes, with file/manual stock imports, unique order IDs, a purchase panel, and order recovery.

Which payment provider should it use for checkout (for example, Stripe)?

wz_ly

litecoin

Kodari AI
KodariOct 20 at 6:38 am 1
  1. Create a Python 3.12 slash-command shop with Litecoin checkout through BTCPay Server.

  2. Add stock import from TXT/CSV/JSON, manual stock entry, unique orders, a shop panel, and order recovery.

  3. Restrict the catalog to Minecraft products and authorized Nitro gift codes.

Created a Python 3.12 Discord shop bot with Litecoin checkout via BTCPay Server.

  • Shop and checkout: /shop publishes a product panel; selecting an item creates a unique order ID and Litecoin invoice. Stock is reserved while the invoice is pending, and delivery is sent by DM after payment settles.

  • Product and stock management: /product_add, /stock_add, /inventory_import (TXT, CSV, or JSON), /products, and /inventory.

  • Order recovery: /order_recover lets the buyer retrieve a delivered order.

  • Files: bot.py, requirements.txt, and .env.example.

Copy .env.example to .env and set your Discord token and BTCPay credentials. Your BTCPay store must support LTC payments. The catalog is limited to Minecraft products and authorized Nitro gift codes; it does not support aged accounts, fake members, OTT access, or Discord boost sales.

Kodari can make mistakes. Review important code before using.
Files
bot.py
requirements.txt
Code
2 598
bot.py
import asyncio
import csv
import io
import json
import logging
import math
import os
import secrets
import sqlite3
from pathlib import Path

import aiohttp
import discord
from discord import app_commands
from discord.ext import commands, tasks
from dotenv import load_dotenv


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


class ShopStore:
    def __init__(self, database_path: str):
        self.database_path = database_path
        self.initialize()

    def connect(self) -> sqlite3.Connection:
        connection = sqlite3.connect(self.database_path)
        connection.row_factory = sqlite3.Row
        connection.execute("PRAGMA foreign_keys = ON")
        return connection

    def initialize(self) -> None:
        Path(self.database_path).parent.mkdir(parents=True, exist_ok=True)
        with self.connect() as db:
            db.executescript(
                """
                CREATE TABLE IF NOT EXISTS products (
                    id TEXT PRIMARY KEY,
                    name TEXT NOT NULL,
                    category TEXT NOT NULL,
                    description TEXT NOT NULL,
                    price_ltc REAL NOT NULL,
                    active INTEGER NOT NULL DEFAULT 1
                );
                CREATE TABLE IF NOT EXISTS stock (
                    id INTEGER PRIMARY KEY AUTOINCREMENT,
                    product_id TEXT NOT NULL REFERENCES products(id),
                    item TEXT NOT NULL,
                    status TEXT NOT NULL DEFAULT 'available',
                    order_id TEXT UNIQUE
                );
                CREATE TABLE IF NOT EXISTS orders (
                    order_id TEXT PRIMARY KEY,
                    user_id INTEGER NOT NULL,
                    product_id TEXT NOT NULL REFERENCES products(id),
                    amount_ltc REAL NOT NULL,
                    invoice_id TEXT,
                    payment_url TEXT,
                    status TEXT NOT NULL,
                    stock_id INTEGER NOT NULL REFERENCES stock(id),
                    delivery TEXT,
                    created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
                );
                CREATE INDEX IF NOT EXISTS orders_status_idx ON orders(status);
                """
            )

    def list_products(self) -> list[dict]:
        with self.connect() as db:
            rows = db.execute(
                "SELECT * FROM products WHERE active = 1 ORDER BY name COLLATE NOCASE"
            ).fetchall()
        return [dict(row) for row in rows]

    def get_product(self, product_id: str) -> dict | None:
        with self.connect() as db:
            row = db.execute(
                "SELECT * FROM products WHERE id = ? AND active = 1", (product_id.upper(),)
            ).fetchone()
        return dict(row) if row else None

    def add_product(self, name: str, category: str, description: str, price_ltc: float) -> str:
        product_id = secrets.token_hex(4).upper()
        with self.connect() as db:
            db.execute(
                "INSERT INTO products (id, name, category, description, price_ltc) VALUES (?, ?, ?, ?, ?)",
                (product_id, name.strip(), category, description.strip(), price_ltc),
            )
        return product_id

    def add_stock(self, product_id: str, items: list[str]) -> int:
        with self.connect() as db:
            db.executemany(
                "INSERT INTO stock (product_id, item) VALUES (?, ?)",
                [(product_id.upper(), item) for item in items],
            )
        return len(items)

    def stock_counts(self, product_id: str) -> tuple[int, int]:
        with self.connect() as db:
            rows = db.execute(
                "SELECT status, COUNT(*) AS count FROM stock WHERE product_id = ? GROUP BY status",
                (product_id.upper(),),
            ).fetchall()
        counts = {row["status"]: row["count"] for row in rows}
        return counts.get("available", 0), counts.get("reserved", 0)

    def create_reserved_order(self, user_id: int, product_id: str) -> tuple[str, dict] | None:
        with self.connect() as db:
            db.execute("BEGIN IMMEDIATE")
            product = db.execute(
                "SELECT * FROM products WHERE id = ? AND active = 1", (product_id.upper(),)
            ).fetchone()
            if not product:
                return None
            stock = db.execute(
                "SELECT id FROM stock WHERE product_id = ? AND status = 'available' ORDER BY id LIMIT 1",
                (product_id.upper(),),
            ).fetchone()
            if not stock:
                return None
            order_id = secrets.token_hex(6).upper()
            while db.execute("SELECT 1 FROM orders WHERE order_id = ?", (order_id,)).fetchone():
                order_id = secrets.token_hex(6).upper()
            db.execute(
                "INSERT INTO orders (order_id, user_id, product_id, amount_ltc, status, stock_id) "
                "VALUES (?, ?, ?, ?, 'creating', ?)",
                (order_id, user_id, product_id.upper(), product["price_ltc"], stock["id"]),
            )
            db.execute(
                "UPDATE stock SET status = 'reserved', order_id = ? WHERE id = ?",
                (order_id, stock["id"]),
            )
            return order_id, dict(product)

    def set_invoice(self, order_id: str, invoice_id: str, payment_url: str) -> None:
        with self.connect() as db:
            db.execute(
                "UPDATE orders SET invoice_id = ?, payment_url = ?, status = 'pending' "
                "WHERE order_id = ? AND status = 'creating'",
                (invoice_id, payment_url, order_id),
            )

    def fail_order(self, order_id: str) -> None:
        with self.connect() as db:
            db.execute(
                "UPDATE stock SET status = 'available', order_id = NULL "
                "WHERE order_id = ? AND status = 'reserved'",
                (order_id,),
            )
            db.execute(
                "UPDATE orders SET status = 'failed' WHERE order_id = ? AND status = 'creating'",
                (order_id,),
            )

    def pending_orders(self) -> list[dict]:
        with self.connect() as db:
            rows = db.execute(
                "SELECT order_id, invoice_id, user_id FROM orders WHERE status = 'pending'"
            ).fetchall()
        return [dict(row) for row in rows]

    def complete_order(self, order_id: str) -> tuple[int, str] | None:
        with self.connect() as db:
            db.execute("BEGIN IMMEDIATE")
            order = db.execute(
                "SELECT user_id, stock_id, status FROM orders WHERE order_id = ?", (order_id,)
            ).fetchone()
            if not order or order["status"] != "pending":
                return None
            stock = db.execute(
                "SELECT item FROM stock WHERE id = ? AND status = 'reserved' AND order_id = ?",
                (order["stock_id"], order_id),
            ).fetchone()
            if not stock:
                logger.error("Reserved stock missing for paid order %s", order_id)
                return None
            db.execute("UPDATE stock SET status = 'delivered' WHERE id = ?", (order["stock_id"],))
            db.execute(
                "UPDATE orders SET status = 'delivered', delivery = ? WHERE order_id = ?",
                (stock["item"], order_id),
            )
            return order["user_id"], stock["item"]

    def expire_order(self, order_id: str) -> None:
        with self.connect() as db:
            db.execute("BEGIN IMMEDIATE")
            db.execute(
                "UPDATE stock SET status = 'available', order_id = NULL "
                "WHERE order_id = ? AND status = 'reserved'",
                (order_id,),
            )
            db.execute(
                "UPDATE orders SET status = 'expired' WHERE order_id = ? AND status = 'pending'",
                (order_id,),
            )