Files
cogs
config.py
database.py
main.py
requirements.txt
slot_db.py
slot_main.py
utils.py
Code
17 3,689
main.py
import discord
from discord.ext import commands
import os
import asyncio
import logging
from dotenv import load_dotenv
import database as db
import config
load_dotenv()
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
datefmt="%Y-%m-%d %H:%M:%S"
)
logger = logging.getLogger("MarketplaceBot")
intents = discord.Intents.all()
bot = commands.Bot(
command_prefix=config.PREFIX,
intents=intents,
help_command=None
)
COGS = [
"cogs.tickets",
"cogs.middleman",
"cogs.wallet",
"cogs.shop",
"cogs.reviews",
"cogs.leaderboard",
"cogs.invites",
"cogs.giveaway",
"cogs.admin",
]
@bot.event
async def on_ready():
logger.info(f"Logged in as {bot.user} (ID: {bot.user.id})")
logger.info(f"Serving {len(bot.guilds)} guild(s)")
await bot.change_presence(
activity=discord.Activity(
type=discord.ActivityType.watching,
name=f",help | Marketplace Bot"
)
)
@bot.event
async def on_command_error(ctx, error):
if isinstance(error, commands.MissingRequiredArgument):
await ctx.send(embed=discord.Embed(
title="Missing Argument",
description=f"Missing required argument: `{error.param.name}`",
color=config.ERROR_COLOR
))
elif isinstance(error, commands.MemberNotFound):
await ctx.send(embed=discord.Embed(
title="Member Not Found",
description="Could not find that member. Please mention them or use their ID.",
color=config.ERROR_COLOR
))
elif isinstance(error, commands.BadArgument):
await ctx.send(embed=discord.Embed(
title="Invalid Argument",
description=str(error),
color=config.ERROR_COLOR
))
elif isinstance(error, commands.MissingPermissions):
await ctx.send(embed=discord.Embed(
title="No Permission",
description="You don't have permission to use this command.",
color=config.ERROR_COLOR
))
elif isinstance(error, commands.CommandNotFound):
pass
elif isinstance(error, commands.CheckFailure):
await ctx.send(embed=discord.Embed(
title="Check Failed",
description="You do not meet the requirements to use this command.",
color=config.ERROR_COLOR
))
else:
logger.error(f"Unhandled error in command '{ctx.command}': {error}", exc_info=error)
@bot.command(name="help")
async def help_command(ctx):
embed = discord.Embed(
title="๐ MarketplaceBot Commands",
description=f"Prefix: `{config.PREFIX}` | All commands listed below",
color=config.BOT_COLOR
)
embed.add_field(
name="๐ซ Tickets",
value=(
"`ticketpanel` โ Post the interactive ticket panel\n"
"`exchangeticket` โ Open an exchange ticket\n"
"`closeticket` โ Close current ticket (Staff)"
),
inline=False
)
embed.add_field(
name="๐ก๏ธ Middleman / Deals",
value=(
"`mmstart @buyer @seller <amount> <desc>` โ Start MM deal\n"
"`dealinfo <code>` โ View deal information\n"
"`logdeal @buyer @seller <amount> <desc>` โ Log a completed deal (Staff)\n"
"`confirm` โ Confirm your part of a deal"
),
inline=False
)
embed.add_field(
name="๐ฐ Wallet & Payments",
value=(
"`bal [@user]` โ View USDT + LTC balance (admin can view others)\n"
"`calc <expression>` โ Safe math calculator\n"
"`usdt` โ Show USDT payment addresses (interactive QR)\n"
"`ltc` โ Show LTC payment addresses (interactive QR)\n"
"`upi` โ Show UPI payment IDs (interactive QR)\n"
"`qr [upi_id]` โ Generate UPI QR code\n"
"`remind @user [msg]` โ Send professional reminder DM (Staff)\n"
"`addusdt @user <amount> [confirmed]` โ Credit USDT (Admin)\n"
"`addltc @user <amount>` โ Credit LTC balance (Admin)\n"
"`confirmbal @user <amount>` โ Confirm unconfirmed USDT (Admin)\n"
"`deductusdt @user <amount>` โ Deduct USDT (Admin)\n"
"`deductltc @user <amount>` โ Deduct LTC (Admin)\n"
"`setusdt <addr> [network] [label]` โ Add USDT pay address (Admin)\n"
"`setltc <addr> [label]` โ Add LTC pay address (Admin)\n"
"`setupi <upi_id> [label]` โ Add UPI ID (Admin)\n"
"`listusdt / listltc / listupi` โ List payment addresses (Admin)\n"
"`delusdt <id> / delltc <id>` โ Delete payment address (Admin)"
),
inline=False
)
embed.add_field(
name="๐ช Shop",
value=(
"`setshop <name> <description>` โ Create/update your shop\n"
"`additem \"Item Name\" <ltc_price>` โ Add item to shop\n"
"`removeitem <item_id>` โ Remove an item\n"
"`toggleitem <item_id>` โ Toggle item availability\n"
"`setbanner <url>` โ Set shop banner image\n"
"`shop [@user]` โ View a shop\n"
"`myshopitems` โ View your items with IDs"
),
inline=False
)
embed.add_field(
name="๐ Reviews & Vouches",
value=(
"`review @user <1-5> <text> [deal:CODE]` โ Leave a review\n"
"`vouch @user <text> [deal:CODE]` โ Leave a vouch\n"
"`reviews [@user]` โ View reviews\n"
"`vouches [@user]` โ View vouches\n"
"`profile [@user]` โ View trading profile"
),
inline=False
)
embed.add_field(
name="๐ Leaderboards",
value=(
"`lbbuyers` โ Top buyers leaderboard\n"
"`lbdealsbystaff` โ Staff deal leaderboard\n"
"`lbinvites` โ Invite leaderboard\n"
"`invites [@user]` โ View invite stats"
),
inline=False
)
embed.add_field(
name="๐ Giveaways",
value=(
"`gstart <duration> <winners> <prize>` โ Start giveaway\n"
"`greroll <message_id>` โ Reroll giveaway winner"
),
inline=False
)
embed.add_field(
name="โ๏ธ Admin / Staff",
value=(
"`setupchannels` โ Create all log channels\n"
"`userinfo [@user]` โ Detailed user info\n"
"`staffinfo [@user]` โ Staff activity info\n"
"`botstats` โ Bot-wide statistics\n"
"`embed [#channel] [Title |] <desc>` โ Send custom embed\n"
"`announce #channel [color] <text>` โ Post announcement\n"
"`dmuser @user <message>` โ DM a user as bot\n"
"`userdm @user <message>` โ DM a user (clean embed)"
),