peeraa11
πŸ“Ž 1 file 3,712 chars
πŸ“„
pasted-code-1782364691232.txt
txt 52 lines
β–Ά
You are an expert Discord bot developer and software architect. I need you to generate a fully functional, highly scalable, and modular Discord bot codebase using discord.js (v14). The bot is named "Plop", and its official website is "plop-bot.xyz". 

Please write the complete code for all files, establish the folder structure, and set up the project so it can run immediately on this hosting environment.

### 1. ENVIRONMENT VARIABLES (.env)
The bot must strictly read and use the following environment variables:
BOT_TOKEN=your_discord_bot_token
OWNER_IDS=id1,id2,id3
CLIENT_ID=your_discord_client_id
CLIENT_SECRET=your_discord_client_secret
DATABASE_URL=your_neon_postgres_url

### 2. DATABASE INTEGRATION (neon.tech)
Connect to PostgreSQL via neon.tech using the DATABASE_URL. Create schemas to manage:
- GuildSettings (prefix, anti-nuke toggles, logging channels)
- PremiumSettings (is_premium: boolean, premium_expires_at: timestamp)
- TemporaryVoice (tracking active voice master channels)

### 3. PREFIX & SLASH COMMAND ARCHITECTURE
- The default text prefix must be a comma `,` (e.g., `,help`).
- The bot must support BOTH text prefix commands and Slash Commands (`/`).
- Create a text-based, owner-only command: `,sync`. When a user listed in OWNER_IDS runs `,sync`, the bot must globally register and synchronize all Slash commands with the Discord API.

### 4. FREE vs. PREMIUM SYSTEM (With Server Customization)
- Standard Tier (Free): Access to basic systems with standard limits.
- Premium Activation: ONLY users listed in OWNER_IDS can grant premium status to a guild using an owner-only command: `,devpremium add [guild_id] [days]`.
- PREMIUM EXCLUSIVE FEATURE: If a guild has active premium status (`is_premium: true`), the Server Owner (Guild Owner) unlocks the ability to customize the bot's identity for that specific server. Provide commands for the Guild Owner to dynamically change the bot's server-specific nickname, custom server-wide bio/about-me, and avatar/banner presentation rules within advanced system embeds. If a non-premium server tries to use these or other premium modules, return a clean, high-tier visual Embed saying the feature is locked.

### 5. CORE MODULES & FEATURES (Everything like Bleed, STRICTLY NO MUSIC/LAST.FM)
Generate separate files/modules for:

A. Advanced Moderation & Utility:
- Kick, ban, unban, softban, timeout, warn system with database logging.
- Purge/clear messages with filters (bots, users, embeds).
- Comprehensive logging (mod-actions, message edits/deletes, member logs).

B. Antinuke & Antiraid (High Security):
- Monitor and rate-limit admin actions (mass channel/role deletion or creation, mass bans, webhook updates).
- If a moderator deletes more than 3 channels within 10 seconds, automatically strip their roles, ban them, and log the action.
- Gatekeeping: Account age limits and profile picture checks on member join.

C. Voicemaster (Dynamic Temporary Voice):
- A "Join to Create" master channel. Creates a temporary voice channel when joined, moves the user, and gives them control.
- Include a button-UI or commands for the channel creator to lock, unlock, limit, or rename their channel. Deletes automatically when empty.

D. Giveaway System:
- Full giveaway management (,gstart, ,greroll, ,gend) backed by database timers to survive bot restarts.NO ONE CAN BE ROLLED MORE THAN 1 TIME ON SAME GIVEAWAY 

E. Embed Scripting Parser:
- A text parser allowing admins to build custom welcome/auto-responses using raw embed codes (e.g., `{embed}{title: Welcome}{description: Hello {user.mention}}`).

Provide clean, error-handled asynchronous JavaScript code for this entire setup.
Kodari AI
KodariJun 25 at 5:32 am 88
PlopBot
Plop is a powerful, fully modular Discord bot built with discord.js v14. Features dual prefix/slash command support, PostgreSQL (Neon) persistence, advanced antinuke & antiraid with automatic role-stripping and bans, dynamic voicemaster with button UI & modals, a complete giveaway system with restart-safe timers, comprehensive moderation suite, message/member logging, embed scripting parser for welcome messages, and a premium tier system with per-server bot customization.


Here’s the complete Plop bot. Here’s an overview of everything included:


πŸ“ Project Structure (53 files)

Plain Text
index.js                          ← Entry point
src/bot.js                        ← Client setup & startup
src/database/index.js             ← PostgreSQL pool & query helper
src/database/schema.js            ← Auto-creates all 7 tables on startup
src/handlers/
  commandHandler.js               ← Recursive prefix command loader
  slashHandler.js                 ← Slash loader + sync utility
  eventHandler.js                 ← Auto-loads all event files
src/utils/
  helpers.js                      ← parseTime, formatTime, pickWinners…
  premiumCheck.js                 ← isPremium() + premium locked embed
src/modules/
  antinuke.js                     ← In-memory threshold tracker + auto-punish
  voicemaster.js                  ← Full VC lifecycle + button/modal handlers
  giveaway.js                     ← Timer-based giveaway engine
  embedParser.js                  ← {embed}{title:…}{description:…} parser
src/events/                       ← 11 events (ready, messages, voice, antinuke…)
src/commands/prefix/              ← 18 prefix commands
src/commands/slash/               ← 9 slash commands

πŸš€ Quick Start

Shell
npm install
# Fill in .env with your real credentials
node index.js

First-time sync β€” run ,sync as a bot owner after startup. Slash commands go live globally within ~1 hour.


πŸ”‘ Key Systems

System
How it works
Antinuke
Tracks channel/role deletes, bans, webhook creates per user in memory. Threshold exceeded β†’ strips roles + auto-bans
Antiraid
On
guildMemberAdd
, checks account age & avatar. Fails = instant kick + log
Voicemaster
Join master VC β†’ bot creates personal VC, sends button controls. Leave β†’ auto-delete
Giveaway
setTimeout
timers persisted in DB, restored on every restart. Entry toggle per-user (no duplicates).
pickWinners
never picks the same person twice
Embed Parser
{embed}{title: Hello}{description: Welcome {user.mention}!}
β€” works in welcome messages
Premium
Only
OWNER_IDS
can grant via
,devpremium add
. Guild owner unlocks
,botstyle
on premium servers
Kodari can make mistakes. Review important code before using.
Files
src
index.js
package.json
Code
52 2,826
src/bot.js
const {
    Client,
    GatewayIntentBits,
    Partials,
    Collection,
    ActivityType,
} = require('discord.js');
const { initDatabase } = require('./database/schema');
const { loadCommands } = require('./handlers/commandHandler');
const { loadSlashCommands } = require('./handlers/slashHandler');
const { loadEvents } = require('./handlers/eventHandler');

const client = new Client({
    intents: [
        GatewayIntentBits.Guilds,
        GatewayIntentBits.GuildMembers,
        GatewayIntentBits.GuildBans,
        GatewayIntentBits.GuildMessages,
        GatewayIntentBits.MessageContent,
        GatewayIntentBits.GuildVoiceStates,
        GatewayIntentBits.GuildMessageReactions,
        GatewayIntentBits.GuildWebhooks,
    ],
    partials: [
        Partials.Message,
        Partials.Channel,
        Partials.Reaction,
        Partials.GuildMember,
        Partials.User,
    ],
});

client.prefixCommands = new Collection();
client.slashCommands = new Collection();
client.cooldowns = new Collection();

client.config = {
    prefix: ',',
    ownerIds: process.env.OWNER_IDS?.split(',').map(id => id.trim()).filter(Boolean) || [],
    website: 'https://plop-bot.xyz',
    color: {
        primary: 0x5865F2,
        success: 0x57F287,
        error: 0xED4245,
        warning: 0xFEE75C,
        premium: 0xF1C40F,
        neutral: 0x2B2D31,
    },
};

client.on('error', err => console.error('[Client] Error:', err));
client.on('warn', msg => console.warn('[Client] Warn:', msg));

async function startBot() {
    console.log('[Bot] Initializing...');
    await initDatabase();
    await loadCommands(client);
    await loadSlashCommands(client);
    await loadEvents(client);
    await client.login(process.env.BOT_TOKEN);
}

module.exports = { client, startBot };