Announcement Commands
Relevant source files
The following files were used as context for generating this wiki page:
Announcement Commands are a subset of the TrackerBot slash command suite designed to facilitate quick communication from the development team to the community. These commands allow authorized users to post standardized notices regarding website stability and maintenance or to send custom messages on behalf of the bot.
The commands are integrated into the Discord.js v14 framework and utilize SlashCommandBuilder for registration. Access is restricted based on specific Discord roles, ensuring that only designated community members or administrators can trigger these public-facing notices.
Sources: README.md:16-19, src/interactions/slashHandlers.js:20-55
Command Definitions and Registration
Commands are defined using the Discord.js SlashCommandBuilder and registered globally via the Discord REST API. The announcement suite primarily consists of /message, /faq1, and /utd.
| Command | Description | Options |
|---|---|---|
/message | Sends a custom message as the bot. | content (String, Required): Supports \n for new lines. |
/faq1 | Posts a predefined FAQ notice regarding website stability. | None |
/utd | Posts a notice indicating an update is in progress. | None |
Sources: src/commands/registerSlashCommands.js:3-17, README.md:65-67
Architecture and Execution Flow
When a user executes a slash command, the interaction is captured by the central interactionHandler.js and routed to the appropriate logic in slashHandlers.js.
Execution Sequence
The following diagram illustrates the lifecycle of an announcement command interaction:
The system first verifies if the member has one of the IDs listed in the allowedCommandRoles set. If the command specifically requires administrative privileges (like /message), it further checks for the "discord admin" role name.
Sources: src/handlers/interactionHandler.js:19-22, src/interactions/slashHandlers.js:13-33, src/config/constants.js:5-11
Logic and Implementation
Custom Messaging (/message)
The /message command allows administrators to broadcast plain text. The implementation manually parses \n characters from the input string to support multi-line formatting before sending the final message to the channel.
const content = interaction.options.getString("content").replace(/\\n/g, "\n");
await interaction.reply({
embeds: [
createCardEmbed({
title: "Message sent",
description: "Your announcement was posted in this channel.",
color: colors.success
})
],
flags: MessageFlags.Ephemeral
});
await interaction.channel.send(content);
Sources: src/interactions/slashHandlers.js:65-80
Predefined Notices (/faq1 and /utd)
These commands provide immediate feedback to the community about the state of the TarkovTracker platform.
- FAQ #1: Informs users about site stability, potential bugs, and data loss risks during iteration.
- UTD (Update In Progress): Notifies users that the tracker is being updated for a new patch and directs them to a specific channel for reporting changes.
Sources: src/interactions/slashHandlers.js:84-102
Permissions and Security
Access control is managed through a combination of environment variables and hardcoded role name checks.
- Role Sets: The bot uses
allowedCommandRoles(derived fromALLOWED_COMMAND_ROLE_IDS) to permit general command usage. - Admin Checks: Commands like
/messageutilize thehasDiscordAdminRolehelper, which scans the member's role cache for a role named "discord admin" (case-insensitive). - DM Protection: The interaction handler explicitly checks
interaction.inGuild()to prevent execution in Direct Messages, which would lack the necessary member and role context.
Sources: src/interactions/slashHandlers.js:13-15, src/interactions/slashHandlers.js:220-222, src/config/constants.js:5-11, src/handlers/interactionHandler.js:10-17
Summary
Announcement Commands serve as a streamlined utility for the TarkovTracker team to manage community expectations and communications. By utilizing standardized embeds through the createCardEmbed utility and strict permission checks, the system ensures consistent and authorized messaging across the Discord server.
Sources: src/utils/cardEmbed.js, src/interactions/slashHandlers.js:13-33