How wivexx/azi-3 works
Project Type & Purpose
• This is an open-source Discord bot (AZI-3) written in Python using the discord.py library.
• It listens to Discord events, routes commands to specialized modules (e.g., bf2 moderation, games, utility), maintains small JSON files for state (logs, reports, banned members), and interacts directly with the Discord API.
File-Structure Analysis
• Top-level scripts:
• azi_3.py – entry point that instantiates the Discord client and loads commands/events
• bot_token.py – configuration (Discord token, constants)
• requirements.txt – lists discord.py and other dependencies
• hidden_script/leave.py – auxiliary script (e.g., leave-server logic)
• . json files (log_channel_ids.json, reports.json) – flat-file data stores
• “script/” directory:
• commands/ – organized by domain (bf2, games, uncategorized, useful)
• events/ – centralized event-listener definitions + banned_member_folder storage
• No database or external microservices—state is held in JSON files.
Key Components
a. Bot Client
• Connects to Discord API via WebSocket
• Loads command modules and event handlers
b. Event Dispatcher
• Receives raw events (e.g., on_message, on_member_join)
• Delegates to script/events/events.py or hidden_script modules
c. Command Handler
• Parses commands (prefix based)
• Routes to the correct module inside script/commands/**
d. Command Modules
• bf2/ moderation (ban, kick, blacklist management, reporting)
• bf2/ regiment, sessions, specialites (role assignments, session launches)
• useful/ (user_info, server_info, password utilities)
• uncategorized/ (ping, say, display_commands)
e. Data Stores
• JSON files: log_channel_ids.json, reports.json, banned_member lists
f. External Service
• Discord API (chat messages, guild membership, reactions, etc.)
Relationships & Data Flows
• Bot Client → Discord API: authenticate, subscribe to events, send/receive messages
• Discord API → Event Dispatcher → Command Handler (for “message” events)
• Command Handler ↔ Command Modules: invoke handlers based on prefix and command name
• Command Modules ↔ JSON Data Stores: read/write file state (reports, logs, ban lists)
• Command Modules → Discord API: send messages, embed responses, assign roles
• Hidden Script Module (leave.py) may be triggered on a specific event (e.g., on_guild_remove)
Architectural Patterns & Principles
• Event-driven architecture using discord.py’s callback model
• Modular command registration—for each file under script/commands/**
• Flat-file storage pattern for simplicity (no external DB)
• Separation of concerns: commands vs events vs configuration vs data
Detail Level
• Bot_token.py as a configuration loader used by the Bot Client