Alegacy Discord Bot

Features

City and Faction Management

The bot maintains a registry of cities and factions stored in JSON files. Each city has an owner, a list of players, a Discord role for access control, a short tag, an optional description, and an optional faction membership. Factions group cities under a leader city and have their own role, tag, and description. Cities can choose to display either their own tag or their faction’s tag in the game via the Pterodactyl console. The bot supports case-insensitive lookup for city and faction names.

Application System

Players submit city and faction applications through interactive Discord forms. City applications use a multi-step wizard with modals for basic info, residents and trusted players, and optional Discord settings. Faction applications require a leader city with at least 20 players. Applications are sent to configurable review channels where admins approve or reject them via persistent buttons. Approved applications create the corresponding city or faction and optionally notify the applicant via DM.

Game Server Integration

The bot connects to a Pterodactyl panel to send console commands to the game server. This is used to set or remove player tags when they join or leave cities, and to run scheduled or one-time commands. The Pterodactyl service can also download log files for monitoring.

Automatic Commands on Player Join

Admins can configure commands that run when specific players join the server. The bot watches a configured channel for specific messages, and when a matching player name is found, it executes the associated command through Pterodactyl and removes the entry (one-time use).

Administrative Tools

Administrators can set the server chat channel, manage bot admins, configure city and faction application channels, create or edit cities and factions directly (including roles, owners, tags), rename cities and factions, mute users, manage tags, and collect or monitor logs. Slash command groups such as cityadmin and factionadmin use Discord’s default administrator permission for access control.

Tech Stack

The project is written in Python and uses discord.py for the Discord API. Configuration is loaded from environment variables via python-dotenv. Async HTTP requests use aiohttp. The py-dactyl library provides the Pterodactyl client. Data is stored in JSON files for cities, factions, applications, player commands, and bot settings. Logging is configured to write to a log file and the console. The bot runs as a systemd service with unbuffered Python output sent to syslog.