Welcome Automation
Relevant source files
The following files were used as context for generating this wiki page:
Welcome Automation is a core feature of TrackerBot designed to streamline the onboarding process for new members joining the TarkovTracker Discord server. It automates the assignment of initial roles and manages personalized welcome messages to ensure a consistent first-time experience.
The system operates primarily through Discord event listeners that trigger when a user joins (GuildMemberAdd) or leaves (GuildMemberRemove) the server. This automation reduces manual administrative overhead and ensures new users immediately receive the necessary permissions and information to participate in the community. Sources: README.md:16, src/handlers/memberHandlers.js:14-23
Architecture and Data Flow
The welcome automation logic is centralized within the memberHandlers.js file and registered during the bot's initialization phase in bot.js. The system relies on environment variables for configuration, which are validated at startup to ensure the automation functions correctly. Sources: bot.js:13-26, src/handlers/memberHandlers.js:1-5
Onboarding Process Flow
When a new member joins, the bot concurrently executes two main tasks: assigning a predefined set of roles and posting a greeting in a designated channel.
The diagram above illustrates the parallel execution of role assignment and welcome messaging upon a member joining the guild. Sources: src/handlers/memberHandlers.js:15-18, src/handlers/memberHandlers.js:25-54
Component Breakdown
Role Assignment Logic
The bot automatically applies a standard "user" role (case-insensitive search by name) and up to four additional roles defined via environment variables. This multi-role assignment ensures members have the correct access levels immediately upon arrival. Sources: src/handlers/memberHandlers.js:25-54
| Component | Description | Configuration Source |
|---|---|---|
| Standard Role | Role named "user" (case-insensitive) | Discord Guild Roles |
| Auto-Roles | Four specific Role IDs (1 through 4) | AUTO_ROLE_ID_1 to AUTO_ROLE_ID_4 |
| Admin Overwrite | Manual bulk assignment for existing members | /put-member-role command |
The /put-member-role slash command serves as a maintenance tool, allowing administrators to retroactively apply the fourth auto-role (AUTO_ROLE_ID_4) to all server members who are currently missing it. Sources: src/interactions/slashHandlers.js:154-220
Message Management
Welcome messages are posted to a specific channel defined by WELCOME_CHANNEL_ID. To prevent channel clutter, the bot maintains an in-memory map of member IDs to their specific welcome message IDs. When a member leaves the server, the bot attempts to delete the corresponding welcome message. Sources: src/handlers/memberHandlers.js:7-12, src/handlers/memberHandlers.js:56-78
This sequence shows the cleanup process triggered when a member leaves, ensuring the welcome channel remains tidy. Sources: src/handlers/memberHandlers.js:68-78
Configuration and Environment Variables
The system requires several environment variables to be defined in the .env file. These are validated by the ensureEnvVars utility in src/config/env.js before the bot logs in. Sources: src/config/env.js:1-12, README.md:38-45
Required Variables
WELCOME_CHANNEL_ID: The unique ID of the text channel where welcome messages are posted.AUTO_ROLE_ID_1throughAUTO_ROLE_ID_4: The IDs of roles to be automatically assigned to new members.PANEL_ADMIN_ROLE_ID: Required for administrative commands that interact with member roles.
Sources: src/config/env.js:1-10, src/interactions/slashHandlers.js:155-156
Technical Implementation Details
The implementation uses a simple Map for message tracking, which means the cleanup state is volatile.
// src/handlers/memberHandlers.js:7-12
const welcomeMessages = new Map();
// Note: On bot restart this map is empty, so welcome messages for
// members who joined before the restart cannot be deleted when they leave.
This design choice is noted as "acceptable at this scale," prioritizing simplicity over persistent state for transient welcome messages. Sources: src/handlers/memberHandlers.js:7-12, AGENTS.md:38-40
Summary
Welcome Automation in TrackerBot provides a frictionless entry point for new Discord members by combining immediate role-based access control with personalized greetings. While its message tracking is ephemeral and resides in memory, it provides robust automated cleanup and administrative tools to maintain guild structure and channel hygiene. Sources: README.md:16, src/handlers/memberHandlers.js:1-23