patrick_jane_fan

And make /Warrants custom comamnd so when someone does /warrant it should be: /warrant username, reason image. and amek warrant banner url and make channel_warrant_ID where when a warrant is made it should send tehre. then there should be a button. "Executed" where when somene arrest the suspect that has warrant they should press taht and the button turns into "Executed by the officer" And make another button should "expired" where only the officer made teh warrant can press that. or it becomes expired after 1 month. Also make a staff role id where only the role use teh command. But anotehr role id that can do infraction,promotion and retiremnt

📎 1 file 14,782 chars
📄
pasted-code-1793627046766.txt
txt 537 lines
▶
# COMPLETE FBI DISCORD MANAGEMENT BOT – DEVELOPMENT PROMPT

I want you to build a professional, fully functional Discord bot specifically for an FBI roleplay server.

The bot must include:
- Shift management.
- Staff management.
- Promotion system.
- Infraction system.
- Retirement system.
- FBI information commands.
- Department management.
- Recruitment system.
- Report management.
- Announcement system.
- Separate logging channels.
- Custom embed banner URLs.

IMPORTANT: Every command must actually work. Do not create fake commands, unfinished features, or placeholder responses.

# 1. SHIFT MANAGEMENT SYSTEM

Create a complete shift management system.

### Basic commands

- `/shift start` – Start a shift and save the exact start date and time.
- `/shift end` – End a shift and calculate the total working duration.
- `/shift status` – Show whether someone is on duty or off duty.
- `/shift stats` – Display personal shift statistics.
- `/shift history` – Display previous shifts.
- `/shift leaderboard` – Display staff ranked by total working hours.
- `/shift active` – Display everyone currently on duty.

### Break commands

- `/shift break` – Temporarily pause working time.
- `/shift resume` – Resume working time after a break.

Break time must be tracked separately and excluded from active working hours.

### Administrator commands

- `/shift force-end user:@USER` – Forcefully end another member's shift.
- `/shift reset user:@USER` – Reset shift statistics after confirmation.
- `/shift report` – Generate a staff activity report.

### Shift requirements

- Members cannot start multiple shifts simultaneously.
- Members can only manage their own shifts.
- Authorized administrators can manage other members' shifts.
- Save all shifts permanently.
- Preserve active shifts after bot restarts.

# 2. SHIFT LOGS CHANNEL

Create this configuration command:

`/config logs-channel channel_id:CHANNEL_ID`

Every shift start, shift end, break, resume, and force-end action must automatically send a professional embed to this channel.

### Shift start embed

🟢 SHIFT STARTED

- Staff Member
- Discord User ID
- Start Time
- Date
- Status: ON DUTY

### Shift end embed

🔴 SHIFT ENDED

- Staff Member
- Discord User ID
- Start Time
- End Time
- Total Working Duration
- Break Duration
- Status: OFF DUTY

Include the administrator's name when a shift is forcefully ended.

# 3. PROMOTION MANAGEMENT SYSTEM

Create a complete staff promotion system.

### Commands

- `/promotion give user:@USER rank:NEW_RANK reason:REASON`
- `/promotion history user:@USER`
- `/promotion list`
- `/promotion remove user:@USER reason:REASON`

### Requirements

When a staff member is promoted:
- Save their previous rank.
- Save their new rank.
- Record who authorized the promotion.
- Record the promotion reason.
- Record the date and time.
- Update their Discord rank role automatically if configured.

### Promotion logs channel

Create:

`/config promotion-logs channel_id:CHANNEL_ID`

Every promotion and promotion removal must be logged in this channel.

### Promotion embed

**⭐ STAFF PROMOTION**

- Member: @Username
- Previous Rank: Special Agent
- New Rank: Senior Special Agent
- Authorized By: @Administrator
- Reason: Outstanding performance
- Date: Date and Time

### CUSTOM PROMOTION BANNER URL

Create a separate configuration command:

`/config promotion-banner url:IMAGE_URL`

The configured image URL must appear as a large embed banner at the bottom of every promotion log.

Requirements:
- Accept direct HTTPS image URLs.
- Support PNG, JPG, JPEG, and GIF.
- Save the URL permanently.
- Allow administrators to change or remove the banner.
- If no banner is configured, send the embed without an image.
- Make the banner look professional and consistent.

# 4. INFRACTION MANAGEMENT SYSTEM

Create a complete disciplinary system.

### Commands

- `/infraction issue user:@USER type:TYPE reason:REASON`
- `/infraction history user:@USER`
- `/infraction list`
- `/infraction remove user:@USER infraction_id:ID reason:REASON`
- `/infraction info infraction_id:ID`

### Infraction types

- Verbal Warning
- Written Warning
- Staff Strike
- Formal Infraction
- Final Warning
- Suspension

Allow administrators to customize the available infraction types.

### Requirements

Every infraction must save:
- Unique infraction ID.
- Member's Discord ID.
- Infraction type.
- Reason.
- Administrator who issued it.
- Date and time.
- Current status.

When an infraction is removed, keep the original record and mark it as removed rather than permanently deleting it.

### Infraction logs channel

Create:

`/config infraction-logs channel_id:CHANNEL_ID`

Automatically log every issued or removed infraction.

### Infraction embed

**⚠️ STAFF INFRACTION ISSUED**

- Member: @Username
- Infraction Type: Written Warning
- Reason: Failure to follow department regulations
- Issued By: @Administrator
- Infraction ID: #00125
- Date: Date and Time
- Status: ACTIVE

### CUSTOM INFRACTION BANNER URL

Create:

`/config infraction-banner url:IMAGE_URL`

The configured image must appear as a large banner at the bottom of every infraction log embed.

Requirements:
- Support HTTPS image URLs.
- Support PNG, JPG, JPEG, and GIF.
- Save the banner URL permanently.
- Allow administrators to update or remove it.
- Use the same configured banner for issued and removed infraction logs.

# 5. RETIREMENT MANAGEMENT SYSTEM

Create a complete retirement system.

### Commands

- `/retirement submit reason:REASON`
- `/retirement approve user:@USER`
- `/retirement deny user:@USER reason:REASON`
- `/retirement history user:@USER`
- `/retirement list`
- `/retirement revoke user:@USER reason:REASON`

### Retirement requirements

When someone submits a retirement request:
- Save the request.
- Save their current rank.
- Save their department.
- Save their reason.
- Mark the request as pending.

When an administrator approves retirement:
- Change the member's status to RETIRED.
- Save their final rank.
- Save their department.
- Save their retirement date.
- Record who approved it.
- Preserve all previous shift statistics.
- Preserve promotions and infractions.
- Optionally assign a configured retired-member role.
- Remove configured active staff roles if appropriate.

Never delete their previous staff information.

### Retirement logs channel

Create:

`/config retirement-logs channel_id:CHANNEL_ID`

Automatically log retirement submissions, approvals, denials, and revocations.

### Retirement embed

**🎖️ STAFF RETIREMENT APPROVED**

- Member: @Username
- Final Rank: Deputy Director
- Department: Administration
- Total Hours Worked: 145 Hours
- Total Shifts: 82
- Retirement Reason: Personal reasons
- Approved By: @Administrator
- Retirement Date: Date and Time
- Status: RETIRED

### CUSTOM RETIREMENT BANNER URL

Create:

`/config retirement-banner url:IMAGE_URL`

The configured image URL must appear as a large banner at the bottom of every retirement log embed.

Requirements:
- Accept direct HTTPS image URLs.
- Support PNG, JPG, JPEG, and GIF.
- Save the URL permanently.
- Allow administrators to change or remove it.
- Use the configured banner for retirement submissions, approvals, denials, and revocations.

# 6. FBI INFORMATION COMMANDS

Create the following commands:

- `/sop` – Display FBI Standard Operating Procedures.
- `/10-codes` – Display radio communication 10-codes.
- `/miranda-rights` – Display Miranda rights information.
- `/fbi-ranks` – Display FBI ranks and hierarchy.
- `/departments` – Display available departments.
- `/chain-of-command` – Display the chain of command.
- `/radio-codes` – Display radio communication codes.
- `/fbi-rules` – Display FBI department rules.
- `/uniform-guide` – Display uniform requirements.
- `/training-info` – Display training information.

Administrators must be able to configure the information displayed by these commands.

# 7. DEPARTMENT MANAGEMENT

Create:

- `/department-info` – Display department information.
- `/department-roster` – Display department members.
- `/department-leadership` – Display department leadership.
- `/assign-department` – Assign a member to a department.
- `/remove-department` – Remove a member from a department.

Include configurable departments such as:

- SWAT
- HRT
- CID
- Internal Affairs
- Criminal Investigation
- Field Operations
- Administration

Allow administrators to configure department names and Discord role IDs.

# 8. LAW ENFORCEMENT REPORT SYSTEM

Create:

- `/arrest-report`
- `/incident-report`
- `/investigation-report`
- `/warrant-info`
- `/case-status`
- `/evidence-log`
- `/suspect-info`

Reports should include:
- Report title.
- Reporting officer.
- Date and time.
- Description.
- People involved.
- Case number.
- Report status.

Save reports permanently and send them to a configurable reports channel.

These features are intended for fictional roleplay documentation and server organization.

# 9. ANNOUNCEMENT COMMANDS

Create:

- `/fbi-announcement`
- `/code-red`
- `/training-announcement`
- `/meeting-announcement`
- `/recruitment`
- `/promotion-announcement`

Allow authorized staff to publish professional embeds.

# 10. STAFF MANAGEMENT COMMANDS

Create:

- `/staff-list` – Display all FBI staff.
- `/staff-info` – Display staff information.
- `/promote` – Promote a member.
- `/demote` – Demote a member.
- `/loa` – Submit a Leave of Absence request.
- `/loa-list` – Display members on leave.
- `/disciplinary-record` – Display disciplinary history.
- `/warning` – Issue a staff warning.
- `/strike` – Issue a staff strike.

Make sure promotions, warnings, strikes, and demotions are saved and logged.

# 11. RECRUITMENT SYSTEM

Create:

- `/apply` – Display FBI application information.
- `/application-status` – Check application status.
- `/accept-application` – Accept an applicant.
- `/deny-application` – Deny an applicant.
- `/interview-info` – Display interview information.
- `/recruitment-status` – Show whether recruitment is open or closed.

Allow administrators to configure application questions and recruitment settings.

# 12. ADDITIONAL COMMANDS

Create:

- `/userinfo` – Display Discord member information.
- `/serverinfo` – Display server information.
- `/ping` – Display bot latency.
- `/suggestion` – Submit a suggestion.
- `/report-member` – Report a member to administration.
- `/complaint` – Submit a complaint.
- `/help` – Display all bot commands.
- `/staff-profile user:@USER` – Display a member's complete FBI career profile.

The staff profile should show:
- Current rank.
- Department.
- Staff status.
- Total shifts.
- Total hours worked.
- Promotion history.
- Infraction history.
- Retirement status.

# 13. COMPLETE CONFIGURATION SYSTEM

Create an administrator configuration system.

The following channels must be configurable separately:

- Shift logs.
- Promotion logs.
- Infraction logs.
- Retirement logs.
- Administrative audit logs.
- Reports.
- Announcements.
- Recruitment.

Also allow administrators to configure:

- Administrator role IDs.
- Supervisor role IDs.
- Staff role IDs.
- Department role IDs.
- Retired member role ID.
- Rank role IDs.
- Promotion banner URL.
- Infraction banner URL.
- Retirement banner URL.

Every configuration must be saved permanently and survive bot restarts.

# 14. ADMINISTRATIVE AUDIT LOGS

Create one central administrative audit channel.

Record:
- Promotions.
- Demotions.
- Infractions.
- Infraction removals.
- Retirement approvals.
- Retirement denials.
- Retirement revocations.
- Shift force-ends.
- Staff role changes.
- Configuration changes.

Every log must show who performed the action, who was affected, the date, and the reason when applicable.

Keep the individual promotion, infraction, retirement, and shift logs separate as well.

# 15. DESIGN AND EMBED REQUIREMENTS

Make the bot look professional and consistent.

Use:
- Green for successful shift starts.
- Red for shift endings.
- Gold for promotions.
- Orange for infractions.
- Purple or dark blue for retirements.
- Blue for general information.
- Timestamps.
- User avatars where appropriate.
- Large custom banner images for promotion, infraction, and retirement embeds.

Use ephemeral responses for private confirmations and errors when appropriate.

The three banner URLs must be independently configurable. Changing the promotion banner must never change the infraction or retirement banner.

# 16. DATABASE AND SECURITY

Use SQLite for a simple installation or PostgreSQL for a larger server.

Permanently save:
- Staff information.
- Shift history.
- Active shifts.
- Break information.
- Shift statistics.
- Promotions.
- Infractions.
- Retirement records.
- Departments.
- Reports.
- Applications.
- Configuration settings.
- Banner URLs.
- Audit logs.

Security:
- Members can only manage their own shifts.
- Only authorized administrators can manage other members.
- Only authorized staff can promote or demote members.
- Only authorized administrators can issue or remove infractions.
- Only authorized administrators can approve or revoke retirements.
- Only authorized administrators can change configuration.
- Check Discord role IDs before executing restricted commands.

Never permanently erase important staff history. Use archived or revoked statuses instead.

# 17. FINAL DEVELOPMENT REQUIREMENTS

I want ONE complete Discord bot, not multiple separate bots.

Make sure:
1. All commands actually work.
2. All data is saved permanently.
3. The bot survives restarts.
4. Multiple users can use the shift system simultaneously.
5. All logs go to the correct configured channels.
6. All three custom banner URLs work independently.
7. All administrator commands have permission checks.
8. Embeds look professional.
9. All systems share the same staff database.
10. No commands are left unfinished.

Test every command before declaring the project complete.

FINAL GOAL:

Build a complete FBI Discord management system that handles staff shifts, promotions, infractions, retirements, departments, reports, recruitment, and administration.

I want the bot to feel like a professional FBI personnel management system, with a clean Discord interface, permanent records, automatic logging, and customizable banners.
Kodari AI
KodariNov 2 at 1:58 pm 2
FBIStaffManager
A comprehensive Discord bot for FBI roleplay servers featuring shift management with breaks and leaderboards, promotion and infraction systems with custom banner embeds, retirement processing, department management, recruitment, law enforcement reports, announcements, and staff profiles. Includes configurable logging channels, role-based permissions, SQLite persistence, and professional embed styling with independent banner URLs for promotions, infractions, and retirements.
  1. Build the Discord.js bot entry point with persistent SQLite records and role-based permissions.

  2. Add warrant creation, configurable warrant channel/banner, persistent action buttons, officer execution, creator-only expiration, and automatic 30-day expiry.

  3. Add working shift, promotion, infraction, retirement, department, report, information, and configuration commands, plus startup instructions.

Created the Discord.js bot with persistent SQLite records, including warrants with execution buttons and creator-only manual expiry. Active warrants expire automatically after 30 days. It also includes shift tracking, promotions, infractions, retirements, departments, reports, recruitment, information, and configuration commands.

To run it, copy .env.example to .env, add your DISCORD_TOKEN, then run npm install and npm start. The bot registers its slash commands at startup; no privileged Gateway Intents need to be enabled.

Configure the warrant channel with /config channel type:warrant, and configure access with /config roles: use staff for warrant actions and management or supervisor for promotion, infraction, and retirement management. Warrant and other banner URLs are managed with /config banner.

Kodari can make mistakes. Review important code before using.
Files
bot.js
package.json
Code
2 848
bot.js
require('dotenv').config();

const {
  ActionRowBuilder,
  ButtonBuilder,
  ButtonStyle,
  ChannelType,
  Client,
  EmbedBuilder,
  GatewayIntentBits,
  PermissionFlagsBits,
  SlashCommandBuilder
} = require('discord.js');
const Database = require('better-sqlite3');

if (!process.env.DISCORD_TOKEN) {
  throw new Error('DISCORD_TOKEN is missing. Add it to your .env file.');
}

const db = new Database('fbi-management.sqlite');
db.pragma('journal_mode = WAL');
db.pragma('foreign_keys = ON');
db.exec(`
  CREATE TABLE IF NOT EXISTS settings (guild_id TEXT NOT NULL, key TEXT NOT NULL, value TEXT NOT NULL, PRIMARY KEY (guild_id, key));
  CREATE TABLE IF NOT EXISTS shifts (id INTEGER PRIMARY KEY AUTOINCREMENT, guild_id TEXT NOT NULL, user_id TEXT NOT NULL, started_at INTEGER NOT NULL, ended_at INTEGER, break_total INTEGER NOT NULL DEFAULT 0, break_started_at INTEGER, status TEXT NOT NULL DEFAULT 'active', ended_by TEXT);
  CREATE TABLE IF NOT EXISTS promotions (id INTEGER PRIMARY KEY AUTOINCREMENT, guild_id TEXT NOT NULL, user_id TEXT NOT NULL, old_rank TEXT NOT NULL, new_rank TEXT NOT NULL, reason TEXT NOT NULL, actor_id TEXT NOT NULL, created_at INTEGER NOT NULL, status TEXT NOT NULL DEFAULT 'active');
  CREATE TABLE IF NOT EXISTS infractions (id INTEGER PRIMARY KEY AUTOINCREMENT, guild_id TEXT NOT NULL, user_id TEXT NOT NULL, type TEXT NOT NULL, reason TEXT NOT NULL, actor_id TEXT NOT NULL, created_at INTEGER NOT NULL, status TEXT NOT NULL DEFAULT 'active', removed_by TEXT, removed_reason TEXT);
  CREATE TABLE IF NOT EXISTS retirements (id INTEGER PRIMARY KEY AUTOINCREMENT, guild_id TEXT NOT NULL, user_id TEXT NOT NULL, rank TEXT NOT NULL, department TEXT NOT NULL, reason TEXT NOT NULL, status TEXT NOT NULL, submitted_at INTEGER NOT NULL, action_by TEXT, action_at INTEGER, action_reason TEXT);
  CREATE TABLE IF NOT EXISTS warrants (id TEXT PRIMARY KEY, guild_id TEXT NOT NULL, suspect_id TEXT NOT NULL, suspect_name TEXT NOT NULL, reason TEXT NOT NULL, image_url TEXT NOT NULL, created_by TEXT NOT NULL, created_at INTEGER NOT NULL, expires_at INTEGER NOT NULL, status TEXT NOT NULL DEFAULT 'active', executed_by TEXT, channel_id TEXT, message_id TEXT);
  CREATE TABLE IF NOT EXISTS departments (guild_id TEXT NOT NULL, name TEXT NOT NULL, role_id TEXT, PRIMARY KEY (guild_id, name));
  CREATE TABLE IF NOT EXISTS department_members (guild_id TEXT NOT NULL, user_id TEXT NOT NULL, department TEXT NOT NULL, PRIMARY KEY (guild_id, user_id));
  CREATE TABLE IF NOT EXISTS reports (id INTEGER PRIMARY KEY AUTOINCREMENT, guild_id TEXT NOT NULL, type TEXT NOT NULL, title TEXT NOT NULL, reporter_id TEXT NOT NULL, people TEXT NOT NULL, description TEXT NOT NULL, case_number TEXT NOT NULL, status TEXT NOT NULL DEFAULT 'Open', created_at INTEGER NOT NULL);
`);

const client = new Client({ intents: [GatewayIntentBits.Guilds] });
const DAY = 24 * 60 * 60 * 1000;
const COLORS = { green: 0x2ecc71, red: 0xe74c3c, gold: 0xf1c40f, orange: 0xe67e22, purple: 0x8e44ad, blue: 0x3498db, gray: 0x7f8c8d };
const INFO_TOPICS = {
  sop: ['FBI Standard Operating Procedures', 'Department procedures have not been configured. Ask an administrator to use `/info set`.'],
  '10-codes': ['Radio 10-Codes', '10-codes have not been configured. Ask an administrator to use `/info set`.'],
  'miranda-rights': ['Miranda Rights', 'Miranda rights information has not been configured. Ask an administrator to use `/info set`.'],
  'fbi-ranks': ['FBI Ranks', 'The rank hierarchy has not been configured. Ask an administrator to use `/info set`.'],
  'chain-of-command': ['Chain of Command', 'The chain of command has not been configured. Ask an administrator to use `/info set`.'],
  'radio-codes': ['Radio Codes', 'Radio codes have not been configured. Ask an administrator to use `/info set`.'],
  'fbi-rules': ['FBI Rules', 'Department rules have not been configured. Ask an administrator to use `/info set`.'],
  'uniform-guide': ['Uniform Guide', 'Uniform requirements have not been configured. Ask an administrator to use `/info set`.'],
  'training-info': ['Training Information', 'Training information has not been configured. Ask an administrator to use `/info set`.'],
  'department-info': ['Department Information', 'Department details have not been configured.'],
  'interview-info': ['Interview Information', 'Interview information has not been configured.'],
  'recruitment-status': ['Recruitment Status', 'Recruitment is currently closed.']
};

function getSetting(guildId, key, fallback = '') {
  return db.prepare('SELECT value FROM settings WHERE guild_id = ? AND key = ?').get(guildId, key)?.value ?? fallback;
}

function setSetting(guildId, key, value) {
  db.prepare('INSERT INTO settings (guild_id, key, value) VALUES (?, ?, ?) ON CONFLICT(guild_id, key) DO UPDATE SET value = excluded.value').run(guildId, key, String(value));
}

function makeEmbed(title, description, color = COLORS.blue, member = null) {
  const embed = new EmbedBuilder().setTitle(title).setDescription(description).setColor(color).setTimestamp();
  if (member?.user) embed.setThumbnail(member.user.displayAvatarURL());
  return embed;
}

function withBanner(guildId, kind, embed) {
  const url = getSetting(guildId, `${kind}_banner`);
  if (url) embed.setImage(url);
  return embed;
}

function validImageUrl(value) {
  try {
    const url = new URL(value);
    return url.protocol === 'https:' && /\.(png|jpe?g|gif|webp)(\?.*)?$/i.test(url.href);
  } catch {
    return false;
  }
}

function formatDuration(ms) {
  const minutes = Math.max(0, Math.floor(ms / 60000));
  const days = Math.floor(minutes / 1440);
  const hours = Math.floor((minutes % 1440) / 60);
  const remainder = minutes % 60;
  return `${days ? `${days}d ` : ''}${hours}h ${remainder}m`;
}

function hasRole(member, settingKey) {
  const ids = getSetting(member.guild.id, settingKey).split(',').map(value => value.trim()).filter(Boolean);
  return ids.some(id => member.roles.cache.has(id));
}

function isAdministrator(member) {
  return member.permissions.has(PermissionFlagsBits.Administrator) || hasRole(member, 'administrator_role_ids');
}

function canManageStaff(member) {
  return isAdministrator(member) || hasRole(member, 'management_role_ids') || hasRole(member, 'supervisor_role_ids');
}

function canUseWarrants(member) {
  return isAdministrator(member) || hasRole(member, 'staff_role_ids') || hasRole(member, 'warrant_role_ids');
}

function command(name, description) {
  return new SlashCommandBuilder().setName(name).setDescription(description);
}

const commands = [];
const shift = command('shift', 'Manage staff shifts')
  .addSubcommand(s => s.setName('start').setDescription('Start your shift'))
  .addSubcommand(s => s.setName('end').setDescription('End your shift'))
  .addSubcommand(s => s.setName('status').setDescription('Check your shift status').addUserOption(o => o.setName('user').setDescription('Staff member')))
  .addSubcommand(s => s.setName('stats').setDescription('View shift totals').addUserOption(o => o.setName('user').setDescription('Staff member')))
  .addSubcommand(s => s.setName('history').setDescription('View recent shift history').addUserOption(o => o.setName('user').setDescription('Staff member')))
  .addSubcommand(s => s.setName('leaderboard').setDescription('Rank staff by working time'))
  .addSubcommand(s => s.setName('active').setDescription('List staff currently on shift'))
  .addSubcommand(s => s.setName('break').setDescription('Pause your shift for a break'))
  .addSubcommand(s => s.setName('resume').setDescription('Resume your shift'))
  .addSubcommand(s => s.setName('force-end').setDescription('End another member shift').addUserOption(o => o.setName('user').setDescription('Staff member').setRequired(true)))
  .addSubcommand(s => s.setName('reset').setDescription('Archive shift records for a member').addUserOption(o => o.setName('user').setDescription('Staff member').setRequired(true)).addBooleanOption(o => o.setName('confirm').setDescription('Confirm archiving records').setRequired(true)))
  .addSubcommand(s => s.setName('report').setDescription('Generate the staff shift activity report'));
commands.push(shift);

const config = command('config', 'Configure channels, roles, and banners')
  .addSubcommand(s => s.setName('channel').setDescription('Set a logging or output channel').addStringOption(o => o.setName('type').setDescription('Channel type').setRequired(true).addChoices(...['shift-logs', 'promotion-logs', 'infraction-logs', 'retirement-logs', 'audit-logs', 'reports', 'announcements', 'recruitment', 'warrant'].map(x => ({ name: x, value: x })))).addChannelOption(o => o.setName('channel').setDescription('Target text channel').setRequired(true).addChannelTypes(ChannelType.GuildText)))
  .addSubcommand(s => s.setName('roles').setDescription('Configure authorized role IDs (comma-separated)').addStringOption(o => o.setName('type').setDescription('Permission group').setRequired(true).addChoices({ name: 'administrator', value: 'administrator_role_ids' }, { name: 'supervisor', value: 'supervisor_role_ids' }, { name: 'staff', value: 'staff_role_ids' }, { name: 'management', value: 'management_role_ids' }, { name: 'warrant', value: 'warrant_role_ids' }, { name: 'retired', value: 'retired_role_id' })).addStringOption(o => o.setName('role-ids').setDescription('Comma-separated IDs; blank clears').setRequired(true)))
  .addSubcommand(s => s.setName('banner').setDescription('Set or clear a custom banner').addStringOption(o => o.setName('type').setDescription('Banner system').setRequired(true).addChoices({ name: 'promotion', value: 'promotion' }, { name: 'infraction', value: 'infraction' }, { name: 'retirement', value: 'retirement' }, { name: 'warrant', value: 'warrant' })).addStringOption(o => o.setName('url').setDescription('HTTPS image URL; omit to clear').setRequired(false)))
  .addSubcommand(s => s.setName('rank-role').setDescription('Map a rank to a Discord role').addStringOption(o => o.setName('rank').setDescription('Rank name').setRequired(true)).addRoleOption(o => o.setName('role').setDescription('Role to assign').setRequired(true)));
commands.push(config);

commands.push(command('warrant', 'Issue a roleplay arrest warrant')
  .addUserOption(o => o.setName('suspect').setDescription('Person named in the warrant').setRequired(true))
  .addStringOption(o => o.setName('reason').setDescription('Reason for the warrant').setRequired(true).setMaxLength(1000))
  .addStringOption(o => o.setName('image').setDescription('HTTPS evidence image URL').setRequired(true)));
commands.push(command('warrant-list', 'List active warrants'));

const promotion = command('promotion', 'Manage staff promotions')
  .addSubcommand(s => s.setName('give').setDescription('Promote a member').addUserOption(o => o.setName('user').setDescription('Member').setRequired(true)).addStringOption(o => o.setName('rank').setDescription('New rank').setRequired(true)).addStringOption(o => o.setName('reason').setDescription('Reason').setRequired(true)))
  .addSubcommand(s => s.setName('history').setDescription('View promotion history').addUserOption(o => o.setName('user').setDescription('Member').setRequired(true)))
  .addSubcommand(s => s.setName('list').setDescription('List current rank records'))
  .addSubcommand(s => s.setName('remove').setDescription('Revoke a promotion record').addIntegerOption(o => o.setName('id').setDescription('Promotion record ID').setRequired(true)).addStringOption(o => o.setName('reason').setDescription('Reason').setRequired(true)));
commands.push(promotion);

const infraction = command('infraction', 'Manage staff disciplinary records')
  .addSubcommand(s => s.setName('issue').setDescription('Issue an infraction').addUserOption(o => o.setName('user').setDescription('Member').setRequired(true)).addStringOption(o => o.setName('type').setDescription('Infraction type').setRequired(true).addChoices(...['Verbal Warning', 'Written Warning', 'Staff Strike', 'Formal Infraction', 'Final Warning', 'Suspension'].map(x => ({ name: x, value: x })))).addStringOption(o => o.setName('reason').setDescription('Reason').setRequired(true)))
  .addSubcommand(s => s.setName('history').setDescription('View infractions for a member').addUserOption(o => o.setName('user').setDescription('Member').setRequired(true)))
  .addSubcommand(s => s.setName('list').setDescription('List active infractions'))
  .addSubcommand(s => s.setName('remove').setDescription('Mark an infraction as removed').addIntegerOption(o => o.setName('id').setDescription('Infraction ID').setRequired(true)).addStringOption(o => o.setName('reason').setDescription('Removal reason').setRequired(true)))
  .addSubcommand(s => s.setName('info').setDescription('View an infraction record').addIntegerOption(o => o.setName('id').setDescription('Infraction ID').setRequired(true)));
commands.push(infraction);

const retirement = command('retirement', 'Manage retirement requests')
  .addSubcommand(s => s.setName('submit').setDescription('Submit your retirement request').addStringOption(o => o.setName('reason').setDescription('Reason').setRequired(true)))
  .addSubcommand(s => s.setName('approve').setDescription('Approve a retirement').addUserOption(o => o.setName('user').setDescription('Member').setRequired(true)))
  .addSubcommand(s => s.setName('deny').setDescription('Deny a pending retirement').addUserOption(o => o.setName('user').setDescription('Member').setRequired(true)).addStringOption(o => o.setName('reason').setDescription('Reason').setRequired(true)))
  .addSubcommand(s => s.setName('history').setDescription('View retirement history').addUserOption(o => o.setName('user').setDescription('Member').setRequired(true)))
  .addSubcommand(s => s.setName('list').setDescription('List pending retirement requests'))
  .addSubcommand(s => s.setName('revoke').setDescription('Revoke a retirement').addUserOption(o => o.setName('user').setDescription('Member').setRequired(true)).addStringOption(o => o.setName('reason').setDescription('Reason').setRequired(true)));
commands.push(retirement);

const department = command('department', 'Manage departments and memberships')
  .addSubcommand(s => s.setName('configure').setDescription('Create or update a department').addStringOption(o => o.setName('name').setDescription('Department name').setRequired(true)).addRoleOption(o => o.setName('role').setDescription('Optional department role')))
  .addSubcommand(s => s.setName('assign').setDescription('Assign a member to a department').addUserOption(o => o.setName('user').setDescription('Member').setRequired(true)).addStringOption(o => o.setName('name').setDescription('Department').setRequired(true)))
  .addSubcommand(s => s.setName('remove').setDescription('Remove a member from their department').addUserOption(o => o.setName('user').setDescription('Member').setRequired(true)))
  .addSubcommand(s => s.setName('roster').setDescription('Show a department roster').addStringOption(o => o.setName('name').setDescription('Department').setRequired(true)))
  .addSubcommand(s => s.setName('leadership').setDescription('Show department leadership and configured roles'))
  .addSubcommand(s => s.setName('list').setDescription('List configured departments'));
commands.push(department);

const reportCommand = (name, description, type) => command(name, description)
  .addStringOption(o => o.setName('title').setDescription('Report title').setRequired(true))
  .addStringOption(o => o.setName('description').setDescription('Detailed report').setRequired(true).setMaxLength(3000))
  .addStringOption(o => o.setName('people').setDescription('People involved').setRequired(true))
  .addStringOption(o => o.setName('case-number').setDescription('Case/reference number').setRequired(true))
  .setDMPermission(false);
for (const [name, description, type] of [
  ['arrest-report', 'Submit an arrest report', 'Arrest'], ['incident-report', 'Submit an incident report', 'Incident'],
  ['investigation-report', 'Submit an investigation report', 'Investigation'], ['evidence-log', 'Submit an evidence log', 'Evidence']
]) commands.push(reportCommand(name, description, type));
commands.push(command('case-status', 'Check a saved case').addStringOption(o => o.setName('case-number').setDescription('Case/reference number').setRequired(true)));
commands.push(command('warrant-info', 'Look up an active warrant').addStringOption(o => o.setName('id').setDescription('Warrant ID').setRequired(true)));
commands.push(command('suspect-info', 'Show saved roleplay reports for a member').addUserOption(o => o.setName('user').setDescription('Member').setRequired(true)));

commands.push(command('info', 'Set configurable FBI information')
  .addSubcommand(s => s.setName('set').setDescription('Set information shown by a public information command').addStringOption(o => o.setName('topic').setDescription('Information topic').setRequired(true).addChoices(...Object.keys(INFO_TOPICS).map(x => ({ name: x, value: x })))).addStringOption(o => o.setName('text').setDescription('Information text').setRequired(true).setMaxLength(3500))));
for (const topic of Object.keys(INFO_TOPICS)) commands.push(command(topic, INFO_TOPICS[topic][0]));
commands.push(command('departments', 'List available departments'));
commands.push(command('department-roster', 'Show a department roster').addStringOption(o => o.setName('name').setDescription('Department name').setRequired(true)));
commands.push(command('department-leadership', 'Show department role configuration'));
commands.push(command('assign-department', 'Assign a department').addUserOption(o => o.setName('user').setDescription('Member').setRequired(true)).addStringOption(o => o.setName('name').setDescription('Department').setRequired(true)));
commands.push(command('remove-department', 'Remove a member department').addUserOption(o => o.setName('user').setDescription('Member').setRequired(true)));

commands.push(command('staff-profile', 'View a member career profile').addUserOption(o => o.setName('user').setDescription('Member').setRequired(true)));
commands.push(command('staff-list', 'List recorded staff members'));
commands.push(command('staff-info', 'Show staff member information').addUserOption(o => o.setName('user').setDescription('Member').setRequired(true)));
commands.push(command('promote', 'Promote a staff member').addUserOption(o => o.setName('user').setDescription('Member').setRequired(true)).addStringOption(o => o.setName('rank').setDescription('New rank').setRequired(true)).addStringOption(o => o.setName('reason').setDescription('Reason').setRequired(true)));
commands.push(command('demote', 'Record a staff demotion').addUserOption(o => o.setName('user').setDescription('Member').setRequired(true)).addStringOption(o => o.setName('rank').setDescription('New rank').setRequired(true)).addStringOption(o => o.setName('reason').setDescription('Reason').setRequired(true)));