alyssanext231

Make a discord bot for infractions like Birb for a ERLC server Flordia highway patroll

Kodari AI
KodariJun 24 at 8:08 pm 15
FHPInfractionBot
A Discord infraction management bot for a Florida Highway Patrol ERLC community. Features include issuing infractions (warnings, strikes, suspensions, terminations), viewing infraction history per member, removing infractions, and detailed logging to a designated channel. All actions use rich embeds with FHP branding. Supports rank-based permission levels so only authorized staff can issue or manage infractions.

Here’s the full breakdown of your FHP Infraction Bot:


🗂️ File Structure

File
Purpose
bot.py
Entry point, loads cogs, syncs slash commands
config.py
Reads
.env
, defines infraction types & FHP branding
database.py
JSON-based infraction storage with case IDs
cogs/infractions.py
/warn
,
/strike
,
/suspend
,
/terminate
,
/removeinfraction
cogs/history.py
/history
(paginated),
/case
lookup
cogs/admin.py
/infractionsummary
,
/fhphelp

⚙️ Setup

  1. pip install -r requirements.txt

  2. Fill in your .env:

    • DISCORD_TOKEN — your bot token

    • LOG_CHANNEL_ID — channel ID where all infractions are logged

    • STAFF_ROLE_IDS — comma-separated role IDs that can warn/strike

    • SENIOR_STAFF_ROLE_IDS — role IDs that can suspend/terminate/void

    • GUILD_ID — your server ID

  3. python bot.py


🔑 Permission Tiers

  • All members → view their own history

  • Staff roles → /warn, /strike, /history

  • Senior Staff roles → all commands including suspend, terminate, void

Kodari can make mistakes. Review important code before using.
Files
cogs
bot.py
config.py
database.py
requirements.txt
Code
8 659
bot.py
import discord
from discord.ext import commands
from discord import app_commands
import os
import json
import datetime
from dotenv import load_dotenv

load_dotenv()

intents = discord.Intents.all()
bot = commands.Bot(command_prefix="!", intents=intents)

@bot.event
async def on_ready():
    print(f"[FHP] Logged in as {bot.user} ({bot.user.id})")
    try:
        synced = await bot.tree.sync()
        print(f"[FHP] Synced {len(synced)} slash commands.")
    except Exception as e:
        print(f"[FHP] Failed to sync commands: {e}")

async def load_cogs():
    await bot.load_extension("cogs.infractions")
    await bot.load_extension("cogs.history")
    await bot.load_extension("cogs.admin")

import asyncio
asyncio.run(load_cogs()) if not bot.is_ready() else None

async def main():
    await load_cogs()
    await bot.start(os.getenv("DISCORD_TOKEN"))

asyncio.run(main())