A full-featured Discord bot template built with Discord.js v14 and the new Components V2 system. This template demonstrates modern command and event handling, modular slash commands, media galleries, file components, and container-based layouts.
![]() Example 1 |
![]() Example 2 |
![]() Example 3 |
![]() Example 4 |
📦discord.js v14 with v2 components template
┣ 📂data # Optional data storage for bot usage
┣ 📂src
┃ ┣ 📂assets
┃ ┣ 📂config
┃ ┃ ┗ 📜config.json # Bot configuration (color, emojis, etc.)
┃ ┣ 📂console
┃ ┃ ┗ 📜watermark.js # Optional console watermark
┃ ┣ 📂events # Event handlers
┃ ┃ ┣ 📂client
┃ ┃ ┃ ┣ 📜interactionCreate.js # Interaction event handler
┃ ┃ ┃ ┗ 📜ready.js # Ready event handler
┃ ┃ ┗ 📂Other # Other custom events
┃ ┣ 📂handlers # Handlers for events and slash commands
┃ ┃ ┣ 📜event.js
┃ ┃ ┗ 📜slash.js
┃ ┣ 📂slashCommands # Slash command files organized by category
┃ ┃ ┣ 📂Info
┃ ┃ ┃ ┗ 📜ping.js
┃ ┃ ┗ 📂V2 Components
┃ ┃ ┃ ┣ 📜button-1.js
┃ ┃ ┃ ┣ 📜button-2.js
┃ ┃ ┃ ┣ 📜button-3.js
┃ ┃ ┃ ┣ 📜file-components.js
┃ ┃ ┃ ┣ 📜media-gallery.js
┃ ┃ ┃ ┣ 📜menu.js
┃ ┃ ┃ ┣ 📜section.js
┃ ┃ ┃ ┣ 📜separator.js
┃ ┃ ┃ ┣ 📜text-display.js
┃ ┃ ┃ ┗ 📜v2-components.js
┃ ┣ 📂temp # Temporary files (e.g., generated data)
┃ ┣ 📂utils # Utility functions
┃ ┣ 📜index.js
┃ ┗ 📜zarco.js
┣ 📜.env # Environment variables (TOKEN, CLIENTID)
┗ 📜package.json
- Modern slash commands with
SlashCommandBuilder
. - Fully modular event handler with max listeners support.
- V2 Components support:
- TextDisplay – display static text with Markdown.
- Section – group text with thumbnails or buttons.
- Button – clickable buttons (Primary, Secondary, Link, etc.).
- MediaGallery – carousel of images/videos.
- FileBuilder / AttachmentBuilder – send JSON or files.
- Separator – divide content visually.
- ChannelSelectMenu – select a channel interactively.
- ContainerBuilder – aggregate multiple component types into a single layout.
- Automatic slash command registration.
- Dummy JSON generation for testing file components.
- Modular slash commands and events for easy scalability.
- Sharding support for large bots to distribute load across multiple processes.
- Console logs all loaded commands and events in a single box for clarity.
- Clone the repository:
git clone https://github.com/ZarCodeX/discord.js-v14-v2-template.git
cd discord.js-v14-v2-template
- Install dependencies:
npm install
- Create a
.env
file in the root:
TOKEN=YOUR_BOT_TOKEN
CLIENTID=YOUR_CLIENT_ID
- Update
src/config/config.json
for colors, emojis, or other config values.
Start the bot with:
npm start
You should see a consolidated console log with all commands and events loaded.
-
Place command files under
src/slashCommands/[Category]/
. -
Export using either
data
(SlashCommandBuilder) orrun
function. -
Supported components for V2:
text-display.js
section.js
button-1.js / button-2.js / button-3.js
file-components.js
media-gallery.js
menu.js
separator.js
v2-components.js
(example using all components)
- TextDisplay – static text messages.
- Section – text with accessories (Thumbnail, Buttons, Menus).
- Button – clickable interactive buttons.
- MediaGallery – carousel of images/videos.
- FileBuilder / AttachmentBuilder – attach JSON or images.
- Separator – add visual dividers or spacing.
- ChannelSelectMenu – interactive channel selection.
- ContainerBuilder – wraps multiple components into a single structured layout.
All of these components are included in separate commands as examples.
- Change accent colors in
config.json
. - Replace images in
src/assets/
and update paths in commands. - Add your own buttons, menus, or media galleries to create unique interactions.
src/assets
– local images, dummy JSONs, or other media.src/temp
– for temporary files generated by commands.src/utils
– helper functions for reuse.src/handlers
– event and command handlers.
- Ensure
MessageFlags.IsComponentsV2
is set when sending V2 components. - Slash commands are automatically registered at app start.
- All console output for commands/events is consolidated in one box for readability.
MIT License – free to use and modify for personal or commercial projects.
Join the Zarco HQ Discord for help, updates, and discussion.