Namari Griffin

You are an expert full-stack Discord bot developer specializing in Node.js (discord.js v14) and MongoDB (Mongoose). Your task is to build a complete, production-ready, hyper-realistic, FiveM-style custom phone roleplay bot for Discord.

The phone operates as a secure, private physical device—NO app grids, app stores, or public chat clutter. Every personal user interaction, settings menu, and messaging panel must remain strictly private (ephemeral: true), utilizing Discord Modals (Forms) for all text/data inputs, Webhooks for secure system logs and masked communications, and strict Phone Role Verification so that only players possessing the designated server phone role can view or execute the bot's slash commands.

---

SECTION 1: HARDWARE, ONE-TIME SETUP WIZARD & PASSCODE CREATION (Strictly Modal-Based)

  1. External Store Integration: Phone devices and SIM cards are managed/purchased via a separate existing store bot. Your bot registers and activates hardware when players claim items.
  2. Phone Role Restriction Gate:

- The bot must check if the user executing any command possesses the server's configured "Phone Item Role" (stored in ServerConfig). - If a player does not have the required phone role, the command execution must be instantly blocked with an ephemeral message: "❌ You must own a physical phone item (have the required phone role) to use this feature!"

  1. First-Time Setup Wizard (One-Time Only Modal Flow):

- When an eligible owner runs /phone for the very first time (and no device document or registered SIM number exists for them), the bot triggers the setup wizard via Discord Modals (Forms). Once completed, this wizard never runs again for that device. - Step 1 (Phone Number Input Modal): The user enters their desired phone number (e.g., 555-4821). The bot checks if the number is already taken in the database; if unique, it binds that SIM number to their device. - Step 2 (Passcode Setup Modal): Immediately after registering the number, a second modal prompts them to create a secure 4-digit numeric PIN passcode.

  1. Subsequent Access & Lock Screen Security:

- Once the phone is set up, running /phone no longer opens the setup wizard. Instead, it checks if the device is locked (is_locked: true). - If locked, an interactive button prompts them to "Unlock Phone" via a Modal Form asking for their 4-digit PIN. 3 failed attempts trigger a temporary security lockout.

  1. VPN & Identity Masking (Webhook Integration):

- Players can toggle a "VPN / Signal Masker" item via phone settings. - When VPN is ON: Outgoing text messages and calls are routed through secure Webhooks that display a randomized burner number or [RESTRICTED / UNKNOWN] instead of their real registered phone number. - Discord Name Shift Synergy: The bot dynamically pulls the user's current effective global Discord display name/alias for webhook embeds.

---

SECTION 2: THE CORE PHONE HOME SCREEN & BATTERY/CHARGING SYSTEM (Ephemeral)

The /phone command serves as the central hub to access the device home screen (ephemeral) featuring a status panel and action buttons:

  • 📶 Status Bar: Carrier, Signal Strength, Active Phone Number, Live Battery %, Lock Status, Airplane Mode, and VPN Status (Active/Inactive).
  • 📞 Dial / Call Button: Opens a Modal Form to dial a number or choose from contacts. Includes a Voicemail System for unanswered/declined calls.
  • 💬 Messages (SMS & Group Chats) Button: View active individual text threads or group chats (up to 5 numbers) and reply via Modal Forms. Supports MMS / Image Attachments sent securely via Webhooks.
  • 📇 Contacts Button: Add, view, or remove saved names and numbers via private menus and modals.
  • 🚫 Block List Button: Block or unblock specific phone numbers so they cannot text or call you.
  • ⚙️ Settings / VPN Button: Change passcode, toggle Airplane Mode, toggle VPN, manage SIM cards, customize custom ringtones/wallpapers via image URLs, or factory reset / throw away the phone.
  • 🔋 Battery & Charging System:

- Battery drains gradually over time and with active use. - Dead Phone State: If battery_level <= 0, running /phone returns a shutdown screen: 🪫 "Device Dead. Recharge your phone using a Power Bank or at a Charging Station."

---

SECTION 3: ADVANCED ROLEPLAY & CRIMINAL MECHANICS (Secured & Logged)

A. Police Wiretapping, Tracing & VPN Bypass

  • Law enforcement roles (configured via admin panel) can use dedicated police commands (/police wiretap, /police trace, /police cyber-trace).
  • VPN Counterplay: If a target has a VPN active, standard wiretaps capture encrypted static. Police must use a higher-tier /police cyber-trace command to unmask VPN users.
  • Tracing an active voice call displays a 30-second ping timer. VPN users yield generalized location zones.

B. Burner Phones & Destructible SIMs

  • Command /burnersim snap instantly destroys the SIM card, wiping all chat logs and unlinking the number forever.

C. Dynamic Voice Calls & Voice Scramblers

  • Calling triggers an interactive ringing notification with [ 🟢 Accept ] and [ 🔴 Decline ].
  • Accepting creates a private temporary voice channel (📞 Call-[Num1]-[Num2]), locks permissions to those two users, and moves them automatically. Hanging up destroys the channel.

D. 🚨 Emergency 911 & Panic Button Distress Ping (Webhook Broadcast)

  • Running /911 or pressing a hidden physical "Panic Button" shortcut opens an Emergency Modal Form (Location, Incident Type, Description) broadcasting an interactive dispatch embed to police/EMS channels via Webhooks with an [ En Route ] button for officers.

---

SECTION 4: SERVER OWNER CONTROLS & WEBHOOK AUDIT LOGS

A. Server Configuration Panel (/phone-config)

  • Restricted strictly to members with Administrator permissions.
  • Allows configuring key server-wide role IDs and logging channels via Modal Forms or select menus:

- Phone Item Role ID: The mandatory role players must have to use any phone features. - Police Role ID & EMS Role ID. - Logging Channel: Sets a designated private text channel where the bot streams structured embed logs using Webhooks for all administrative actions, phone setups, SIM registrations, battery events, 911 dispatches, and wiretaps.

---

SECTION 5: COMPLETE STANDALONE SLASH COMMAND LIST TO BUILD (Role-Gated)

  1. /phone - Central hub command. Opens the phone home screen, triggers the one-time setup wizard modals (if unconfigured), or prompts for the lock screen PIN on subsequent uses (Requires Phone Role, Ephemeral).
  2. /phone-charge - Recharges the active user's phone battery to 100% using power bank/station inventory items (Requires Phone Role).
  3. /call [number] - Standalone command that initiates a phone call to a target number (Requires Phone Role).
  4. /911 [location] [incident] - Opens a Modal Form to send an emergency dispatch alert via Webhook (Requires Phone Role).
  5. /police wiretap [number] - Standalone law enforcement command to set up an active wiretap on a target SIM card (Requires Police Role).
  6. /police trace [number] - Standalone law enforcement command to trace a phone number or active voice call (Requires Police Role).
  7. /police cyber-trace [number] - Standalone law enforcement command to bypass VPN proxy routing for criminal investigations (Requires Police Role).
  8. /burnersim snap - Standalone command that destroys the current SIM card and wipes all communication logs (Requires Phone Role).
  9. /phone-config - Administrator setup command for configuring roles and logging webhooks via Modal Forms (Requires Admin Permission).

---

SECTION 6: DATABASE SCHEMAS (Mongoose)

  1. ServerConfig: guild_id, phone_item_role_id, police_role_id, ems_role_id, log_channel_id, webhook_url
  2. Device: serial_number, owner_id, sim_number, passcode, is_locked, airplane_mode, vpn_active, has_scrambler, battery_level, wallpaper_url, blocked_numbers
  3. Sim: phone_number, is_wiretapped, wiretap_officer_id
  4. Message: chat_id, sender_number, receiver_number, content, media_url, is_vpn_masked, is_delivered, timestamp
  5. Voicemail: owner_number, sender_number, transcript, timestamp
  6. Contact: owner_number, name, number

---

TECHNICAL REQUIREMENTS & FILE STRUCTURE TO OUTPUT

Provide complete, modular, copy-pasteable code files ensuring all commands check for the mandatory Phone Item Role, the setup wizard triggers strictly once upon initial device creation, all text inputs use Discord Modals (Forms), all user screens use Ephemeral messages (ephemeral: true), and all logs/masked messages use Webhooks:

  1. schemas.js: Complete Mongoose models for all databases (including phone_item_role_id).
  2. configManager.js: Server configuration validation, role-checking utility functions, and Webhook-based audit logging.
  3. phoneSetup.js: One-time modal setup wizard (number registration & 4-digit PIN setup), lock screen security validation, battery level verification checks, and dynamic ephemeral home screen UI.
  4. phoneCore.js: Standalone handlers for /phone-charge, /call, /911, and all /police commands (wiretap, trace, cyber-trace, burnersim) with Webhook-based notifications & temporary voice channels.
  5. index.js: Main Discord client startup, standalone slash command definitions (/phone, /phone-charge, /call, /911, /police wiretap/trace/cyber-trace, /burnersim snap, /phone-config), role-checking permission gates for all commands, and comprehensive interaction routing for all buttons, Modals (Forms), and select menus.
Kodari AI
KodariOct 30 at 4:56 am 4
FiveMPhoneRP
A comprehensive FiveM-style Discord phone roleplay bot with secure device management, one-time modal setup wizard for SIM registration and 4-digit PIN creation, ephemeral home screen with battery/charging system, VPN masking via webhooks, dynamic voice calls with temporary channels, police wiretap/trace/cyber-trace commands, 911 dispatch system, burner SIM destruction, and administrator configuration panel. All interactions use Discord Modals and ephemeral messages with strict phone role verification.
  1. Add the Mongoose schemas and server-role/audit configuration.

  2. Build the private phone setup, PIN, home-screen and interaction flows.

  3. Add charging, calls, dispatch, police tools, command registration and startup.

Created the Discord phone bot project with Mongoose models, role-gated slash commands, private phone setup and PIN lockout, SMS/MMS and group chats, contacts and blocking, VPN masking, voicemail, charging, calls with temporary voice channels, police tools, 911 dispatch, webhook audits, and admin configuration.

To run it, set DISCORD_TOKEN and MONGODB_URI from .env.example. Configure /phone-config with the phone role and a private log channel. The bot needs permission to manage webhooks; temporary calls also require channel management and member-move permissions.

The separate store bot must provision power_bank_count and has_scrambler on a player’s device when those items are claimed. Phone commands enforce role checks when executed; Discord may still display registered slash-command names to users without that role.

Namari Griffin

My hosted Discord bot failed to start: its code has an error and does not run.

Console output:

code
/
/9 packages are looking for funding
/  run `npm fund` for details
/
found 0 vulnerabilities
//home/container/phoneSetup.js:144
.addOptions(contacts.map(contact => ({ label: contact.name.slice(0, 100), description: contact.number.slice(0, 100), value: contact.number }))));
^
SyntaxError: missing ) after argument list
at wrapSafe (node:internal/modules/cjs/loader:1713:18)
at Module._compile (node:internal/modules/cjs/loader:1755:20)
at Object..js (node:internal/modules/cjs/loader:1913:10)
at Module.load (node:internal/modules/cjs/loader:1505:32)
at Function._load (node:internal/modules/cjs/loader:1309:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:254:19)
at Module.require (node:internal/modules/cjs/loader:1527:12)
at require (node:internal/modules/helpers:147:16)
at Object.<anonymous> (/home/container/index.js:12:71)
at Module._compile (node:internal/modules/cjs/loader:1781:14)
Node.js v22.23.0
[Pterodactyl Daemon]: ---------- Detected server process in a crashed state! ----------
[Pterodactyl Daemon]: Exit code: 1
[Pterodactyl Daemon]: Out of memory: false
[Pterodactyl Daemon]: Checking server disk space usage, this could take a few seconds...
[Pterodactyl Daemon]: Updating process configuration files...
[Pterodactyl Daemon]: Ensuring file permissions are set correctly, this could take a few seconds...
[Pterodactyl Daemon]: Pulling Docker container image, this could take a few minutes to complete...
[Pterodactyl Daemon]: Finished pulling Docker container image
Node.js Version: v22.23.0
:/home/container$ if [ -f /home/container/package.json ]; then /usr/local/bin/npm install; fi; START=""; if [ -f /home/container/package.json ]; then START=$(/usr/local/bin/node -p "(require('/home/container/package.json').scripts||{}).start||''"); fi; if echo "$START" | grep -Eq '^node [A-Za-z0-9_.-][A-Za-z0-9_./-]*___CODE_BLOCK___#39;; then exec /usr/local/bin/node /home/container/${START#node }; elif [ -n "$START" ]; then exec /usr/local/bin/npm start; else exec /usr/local/bin/node "/home/container/${MAIN_FILE}" ${NODE_ARGS}; fi

Fix the code so it starts. If it needs something only I can do (like enabling an intent in the Developer Portal or re-inviting the bot), tell me exactly what to do.

Kodari AI
KodariOct 30 at 9:10 pm 1

Fixed the missing closing parenthesis in phoneSetup.js. The startup syntax error should be resolved; no Developer Portal changes are needed for this error.

Namari Griffin

My hosted Discord bot failed to start: its code has an error and does not run.

Console output:

code
/
/9 packages are looking for funding
/  run `npm fund` for details
/
found 0 vulnerabilities
//home/container/phoneSetup.js:144
.addOptions(contacts.map(contact => ({ label: contact.name.slice(0, 100), description: contact.number.slice(0, 100), value: contact.number }))));
^
SyntaxError: missing ) after argument list
at wrapSafe (node:internal/modules/cjs/loader:1713:18)
at Module._compile (node:internal/modules/cjs/loader:1755:20)
at Object..js (node:internal/modules/cjs/loader:1913:10)
at Module.load (node:internal/modules/cjs/loader:1505:32)
at Function._load (node:internal/modules/cjs/loader:1309:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:254:19)
at Module.require (node:internal/modules/cjs/loader:1527:12)
at require (node:internal/modules/helpers:147:16)
at Object.<anonymous> (/home/container/index.js:12:71)
at Module._compile (node:internal/modules/cjs/loader:1781:14)
Node.js v22.23.0
[Pterodactyl Daemon]: ---------- Detected server process in a crashed state! ----------
[Pterodactyl Daemon]: Exit code: 1
[Pterodactyl Daemon]: Out of memory: false
[Pterodactyl Daemon]: Checking server disk space usage, this could take a few seconds...
[Pterodactyl Daemon]: Updating process configuration files...
[Pterodactyl Daemon]: Ensuring file permissions are set correctly, this could take a few seconds...
[Pterodactyl Daemon]: Pulling Docker container image, this could take a few minutes to complete...
[Pterodactyl Daemon]: Finished pulling Docker container image
Node.js Version: v22.23.0
:/home/container$ if [ -f /home/container/package.json ]; then /usr/local/bin/npm install; fi; START=""; if [ -f /home/container/package.json ]; then START=$(/usr/local/bin/node -p "(require('/home/container/package.json').scripts||{}).start||''"); fi; if echo "$START" | grep -Eq '^node [A-Za-z0-9_.-][A-Za-z0-9_./-]*___CODE_BLOCK___#39;; then exec /usr/local/bin/node /home/container/${START#node }; elif [ -n "$START" ]; then exec /usr/local/bin/npm start; else exec /usr/local/bin/node "/home/container/${MAIN_FILE}" ${NODE_ARGS}; fi

Fix the code so it starts. If it needs something only I can do (like enabling an intent in the Developer Portal or re-inviting the bot), tell me exactly what to do.

Kodari AI
KodariOct 30 at 9:12 pm 1

Rewrote the contact select-menu setup in phoneSetup.js to avoid the mismatched-parentheses syntax error. No Developer Portal or bot-invite changes are needed; redeploy the updated code and restart the bot.

Namari Griffin

My hosted Discord bot failed to start: it crashed right after starting.

Console output:

code
[Pterodactyl Daemon]: Exit code: 1
[Pterodactyl Daemon]: Out of memory: false
[Pterodactyl Daemon]: Checking server disk space usage, this could take a few seconds...
[Pterodactyl Daemon]: Updating process configuration files...
[Pterodactyl Daemon]: Ensuring file permissions are set correctly, this could take a few seconds...
[Pterodactyl Daemon]: Pulling Docker container image, this could take a few minutes to complete...
[Pterodactyl Daemon]: Finished pulling Docker container image
Node.js Version: v22.23.0
:/home/container$ if [ -f /home/container/package.json ]; then /usr/local/bin/npm install; fi; START=""; if [ -f /home/container/package.json ]; then START=$(/usr/local/bin/node -p "(require('/home/container/package.json').scripts||{}).start||''"); fi; if echo "$START" | grep -Eq '^node [A-Za-z0-9_.-][A-Za-z0-9_./-]*___CODE_BLOCK___#39;; then exec /usr/local/bin/node /home/container/${START#node }; elif [ -n "$START" ]; then exec /usr/local/bin/npm start; else exec /usr/local/bin/node "/home/container/${MAIN_FILE}" ${NODE_ARGS}; fi
\|/-\
up to date, audited 47 packages in 2s
\
\9 packages are looking for funding
\  run `npm fund` for details
\
found 0 vulnerabilities
\Bot startup failed: Error: MONGODB_URI is missing. Add it to the project environment.
at start (/home/container/index.js:101:39)
at Object.<anonymous> (/home/container/index.js:107:1)
at Module._compile (node:internal/modules/cjs/loader:1781:14)
at Object..js (node:internal/modules/cjs/loader:1913:10)
at Module.load (node:internal/modules/cjs/loader:1505:32)
at Function._load (node:internal/modules/cjs/loader:1309:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:254:19)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:171:5)
at node:internal/main/run_main_module:36:49
[Pterodactyl Daemon]: ---------- Detected server process in a crashed state! ----------
[Pterodactyl Daemon]: Exit code: 1
[Pterodactyl Daemon]: Out of memory: false
[Pterodactyl Daemon]: Aborting automatic restart, last crash occurred less than 60 seconds ago.

Fix the code so it starts. If it needs something only I can do (like enabling an intent in the Developer Portal or re-inviting the bot), tell me exactly what to do.

Kodari AI
KodariOct 30 at 9:15 pm 1

This isn’t a code syntax error: index.js requires MONGODB_URI before logging in, and the phone features use MongoDB for storage. Skipping the database check would let the bot log in but leave those features unable to work.

Add a MONGODB_URI environment variable to the hosted project. If you use MongoDB Atlas, get the connection string from Database → Connect → Drivers and set it in the same place as DISCORD_TOKEN. It should look like:

Env
MONGODB_URI=mongodb+srv://<username>:<encoded-password>@<cluster-host>/<database>?retryWrites=true&w=majority

Replace the placeholders with your Atlas details, make sure the database user and network access are configured, then restart the bot. If you manage secrets through a .env file, add that line there instead. Don’t share the completed URI publicly; it contains credentials.

No Developer Portal intent changes or bot re-invite are needed.

Kodari can make mistakes. Review important code before using.
Files
configManager.js
index.js
package.json
phoneCore.js
phoneSetup.js
schemas.js
Code
6 1,309
index.js
require('dotenv').config();

const {
  Client,
  GatewayIntentBits,
  Partials,
  SlashCommandBuilder
} = require('discord.js');
const mongoose = require('mongoose');
const { handleConfigInteraction, requirePhoneRole, requirePoliceRole } = require('./configManager');
const { handleCoreCommand, handleCoreInteraction, onVoiceStateUpdate } = require('./phoneCore');
const { handlePhoneInteraction, handlePhoneModalAction, openPhone } = require('./phoneSetup');

const client = new Client({
  intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates, GatewayIntentBits.DirectMessages],
  partials: [Partials.Channel]
});

const commands = [
  new SlashCommandBuilder().setName('phone').setDescription('Open or set up your private roleplay phone'),
  new SlashCommandBuilder().setName('phone-charge').setDescription('Recharge your phone using a Power Bank'),
  new SlashCommandBuilder().setName('call').setDescription('Call a registered phone number')
    .addStringOption(option => option.setName('number').setDescription('Phone number, e.g. 555-4821').setRequired(true)),
  new SlashCommandBuilder().setName('911').setDescription('Send an emergency dispatch')
    .addStringOption(option => option.setName('location').setDescription('Incident location (you will confirm it in a private form)').setRequired(false))
    .addStringOption(option => option.setName('incident').setDescription('Incident type').setRequired(false)),
  new SlashCommandBuilder().setName('police').setDescription('Law-enforcement phone tools')
    .addSubcommand(command => command.setName('wiretap').setDescription('Activate a wiretap on a SIM').addStringOption(option => option.setName('number').setDescription('Target number, e.g. 555-4821').setRequired(true)))
    .addSubcommand(command => command.setName('trace').setDescription('Trace a SIM or active call').addStringOption(option => option.setName('number').setDescription('Target number, e.g. 555-4821').setRequired(true)))
    .addSubcommand(command => command.setName('cyber-trace').setDescription('Bypass VPN masking and identify a SIM').addStringOption(option => option.setName('number').setDescription('Target number, e.g. 555-4821').setRequired(true))),
  new SlashCommandBuilder().setName('burnersim').setDescription('Destroy the active burner SIM')
    .addSubcommand(command => command.setName('snap').setDescription('Destroy the SIM and erase associated communications')),
  new SlashCommandBuilder().setName('phone-config').setDescription('Configure phone roles and private audit/dispatch logs')
].map(command => command.toJSON());

client.once('clientReady', async () => {
  try {
    await client.application.commands.set(commands);
    console.log(`Bot is ready! Logged in as ${client.user.tag}`);
    console.log('KODARI_READY');
  } catch (error) {
    console.error('Failed to register slash commands:', error);
    process.exitCode = 1;
  }
});

client.on('interactionCreate', async interaction => {
  try {
    if (await handleConfigInteraction(interaction)) return;

    if (interaction.isChatInputCommand()) {
      if (interaction.commandName === 'phone-config') return;
      if (!await requirePhoneRole(interaction)) return;
      if (interaction.commandName === 'police' && !await requirePoliceRole(interaction)) return;
      if (interaction.commandName === 'phone') return await openPhone(interaction);
      return await handleCoreCommand(interaction);
    }

    if (interaction.isModalSubmit()) {
      if (interaction.customId.startsWith('phone:')) {
        if (!await requirePhoneRole(interaction)) return;
        if (await handlePhoneModalAction(interaction)) return;
        return await handlePhoneInteraction(interaction);
      }
      if (interaction.customId.startsWith('core:911:')) {
        if (!await requirePhoneRole(interaction)) return;
        return await handleCoreInteraction(interaction);
      }
      return;
    }

    if (interaction.isButton() || interaction.isStringSelectMenu()) {
      if (interaction.customId.startsWith('phone:')) {
        if (!await requirePhoneRole(interaction)) return;
        return await handlePhoneInteraction(interaction);
      }
      if (interaction.customId.startsWith('call:')) return await handleCoreInteraction(interaction);
      if (interaction.customId.startsWith('dispatch:')) return await handleCoreInteraction(interaction);
    }
  } catch (error) {
    console.error('Interaction handler failed:', error);
    const payload = { content: '❌ Something went wrong while processing that phone action. Please try again.', ephemeral: true };
    if (interaction.deferred || interaction.replied) {
      await interaction.followUp(payload).catch(() => {});
    } else {
      await interaction.reply(payload).catch(() => {});
    }
  }
});

client.on('voiceStateUpdate', (oldState, newState) => {
  onVoiceStateUpdate(oldState, newState).catch(error => console.error('Voice call cleanup failed:', error));
});

client.on('error', error => console.error('Discord client error:', error));
client.on('shardError', error => console.error('Discord gateway shard error:', error));
process.on('unhandledRejection', error => console.error('Unhandled promise rejection:', error));

async function start() {
  if (!process.env.DISCORD_TOKEN) throw new Error('DISCORD_TOKEN is missing. Add it to the project environment.');
  if (!process.env.MONGODB_URI) throw new Error('MONGODB_URI is missing. Add it to the project environment.');
  await mongoose.connect(process.env.MONGODB_URI);
  console.log('MongoDB connected.');
  await client.login(process.env.DISCORD_TOKEN);
}

start().catch(error => {
  console.error('Bot startup failed:', error);
  process.exit(1);
});