{"id":17703237,"url":"https://github.com/flipeador/discord.js-template","last_synced_at":"2026-05-09T02:06:25.241Z","repository":{"id":259080975,"uuid":"865354441","full_name":"flipeador/discord.js-template","owner":"flipeador","description":"A basic Discord bot application template using DiscordJS.","archived":false,"fork":false,"pushed_at":"2025-09-28T03:23:38.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-25T06:43:45.525Z","etag":null,"topics":["bot-application","discord-bot","discordjs","guild-install","jsdoc","minimal","node-sqlite","nodejs","pnpm","sharding","slash-commands","template","user-install"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flipeador.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-09-30T11:53:32.000Z","updated_at":"2025-09-28T03:23:41.000Z","dependencies_parsed_at":"2024-11-30T15:22:38.648Z","dependency_job_id":"8e9a9165-68e7-4fd5-8df6-8396943153f7","html_url":"https://github.com/flipeador/discord.js-template","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"44d2f369a8800b2faec86b74c17ca5d9040e02c7"},"previous_names":["flipeador/discord.js-template"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/flipeador/discord.js-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flipeador%2Fdiscord.js-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flipeador%2Fdiscord.js-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flipeador%2Fdiscord.js-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flipeador%2Fdiscord.js-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flipeador","download_url":"https://codeload.github.com/flipeador/discord.js-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flipeador%2Fdiscord.js-template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32804632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"online","status_checked_at":"2026-05-09T02:00:06.633Z","response_time":123,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot-application","discord-bot","discordjs","guild-install","jsdoc","minimal","node-sqlite","nodejs","pnpm","sharding","slash-commands","template","user-install"],"created_at":"2024-10-24T20:05:59.351Z","updated_at":"2026-05-09T02:06:25.205Z","avatar_url":"https://github.com/flipeador.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Discord.js Template\n\nA basic Discord bot application template using [Node.js ≥24][v2340][^1] and [Discord.js][djs] v14.\n\nThe template uses the [Discord.js][djs] built-in `ShardingManager` to run shards in [separate processes][node-ipc]. \\\nAlthough [sharding][sharding] is only required at 2500 guilds, doing so in advance should not be a problem.\n\nThe [native `node:sqlite` module][node-sqlite] added in [Node.js 22.5][v2250] is used for the [SQLite][sqlite] database. \\\nCurrently, the module is loaded but the database is not used.\n\n# Instructions\n\nCreate a Discord bot application ([Discord.js Guide - Setting up a bot application][setup]).\n\n\u003e 🤖 Generate an invite link for your application.\n\u003e\n\u003e 1. Navigate to [Discord Developers - Applications][apps].\n\u003e 2. Scroll down and select your app. Copy the **Application ID**.\n\u003e 3. Go to `⚙️ Installation` and select both [installation contexts][insctx].\n\u003e 4. Replace `000000000000000000` with your app ID in the URLs below.\n\u003e\n\u003e Add the bot application to your private test server:\n\u003e ```\n\u003e https://discord.com/oauth2/authorize?client_id=000000000000000000\u0026permissions=2147485696\u0026integration_type=0\u0026scope=bot+applications.commands\n\u003e ```\n\u003e\n\u003e Add the bot application to your user account to use it anywhere:\n\u003e ```\n\u003e https://discord.com/oauth2/authorize?client_id=000000000000000000\u0026integration_type=1\u0026scope=applications.commands\n\u003e ```\n\u003e Adding the bot application to your user account allows its use even on servers where it is not installed. \\\n\u003e The bot's messages will be ephemeral if the invoker has the `Use External Apps` permission disabled. [^2]\n\nBefore starting up the bot, you will need to install and configure a few things.\n\nInstall [pnpm][pnpm], then run the following command in the [Terminal][terminal] to install [Node.js][node]:\n\n```sh\n# Install the latest version of NodeJS.\npnpm env use latest --global\n\n# Once NodeJS is installed, you can close the terminal.\n# We will use the VS Code integrated terminal from now on.\n```\n\n[Clone][clone] this repository to your local computer, open the root directory with [Visual Studio Code][code]. \\\nAlternatively, you can [create a new repository using this template][template], then [clone][clone] your own repository.\n\nRun the following command in the [VS Code Terminal][code-terminal] to install all required dependencies:\n\n```sh\n# Change the current directory.\ncd src\n\n# Install all dependencies for the project.\npnpm install\n\n# Optionally, update all dependencies to their latest versions.\npnpm update --latest\n```\n\nInstall the [VS Code ESLint extension][code-eslint], it helps you find and fix problems with your JavaScript code. \\\nOpen the [VS Code Command Palette][code-palette] with \u003ckbd\u003e\u003ckbd\u003eCTRL\u003c/kbd\u003e+\u003ckbd\u003eSHIFT\u003c/kbd\u003e+\u003ckbd\u003eP\u003c/kbd\u003e\u003c/kbd\u003e,\nand select `Developer: Reload Window`.\n\n\u003cdetails\u003e\n\u003csummary\u003eExpand to see how to run ESLint from the terminal. (OPTIONAL)\u003c/summary\u003e\n\n```sh\n# Check for problems in all files.\nnode --run lint\n\n# Tool for inspecting ESLint configs.\nnode --run lint:ci\n```\n\n\u003c/details\u003e\n\nRename [`.sample.env`](src/.sample.env) to `.env`, and configure the required fields:\n- Set the bot **token**, **application id** and **owner id**.\n- Set a **test server id** in which the bot is in for testing purposes.\n\nRun the following commands to register application commands and start the bot:\n\n```ps1\n# Register all application commands in the test server.\nnode --run reg -- bulk ALL TEST\n\n# Start the bot application and log in to Discord.\nnode --run bot\n```\n\nThe bot should be up and running by now, check the information displayed in the terminal.\n\nContinue reading [Application Commands](#application-commands) to learn how to create and register app commands.\n\n## Application Commands\n\nApplication commands can be scoped either globally or to a specific server.\n\n- **Global commands** are available in all of the servers where your app is installed, and in DMs if the bot shares a mutual server with the user. Register global commands when they're ready for public use.\n- **Guild commands** are only available in the servers you explicitly add them, making them useful for features available only to a subset of servers. Register guild commands for quick testing, as they are updated instantly.\n\n```ps1\n# Register all global commands.\n# The \"ALL\" keyword references all commands in 'src/bot/commands'.\nnode --run reg -- create ALL\n\n# Register all commands in the test server.\n# The \"TEST\" keyword references \"APP_TEST_GUILD_ID\" in the '.env' file.\nnode --run reg -- create ALL TEST\n\n# Delete the \"rolldice\" command in a specific server.\nnode --run reg -- delete rolldice 1234567890123456789\n\n# Multiple commands can be specified by separating them with a comma.\n# The 'src/bot/commands/log.json' file stores a log with all the commands.\n# Use the \"bulk\" action instead of \"create\" to bulk-overwrite all commands.\n# Registering a command with an already-used name will update the existing command.\n```\n\nYou must create the [application commands][appcmds] in [`src/bot/commands`](src/bot/commands) before [registering them][regcmds].\n\nThe following table specifies all available application commands that serve as examples:\n\n| Command | Type | Scope | Integration Types | Tags |\n| --- | --- | --- | --- | --- |\n| [`/eval`](src/bot/commands/chat/eval.js) | Chat input | Server | `user` `guild` | `owner` `modal` |\n| [`/rps`](src/bot/commands/chat/rps.js) | Chat input | Global | `user` `guild` | `fun` `game` |\n| [`/guess`](src/bot/commands/chat/guess.js) | Chat input | Global | `guild` | `fun` `game` [`CV2`][compv2] |\n| [`/blackjack`](src/bot/commands/chat/blackjack.js) | Chat input | Global | `user` `guild` | `fun` `game` |\n| [`/rolldice`](src/bot/commands/chat/rolldice.js) | Chat input | Global | `user` `guild` | `fun` [`CV2`][compv2] |\n| [`Get avatar`](src/bot/commands/user/avatar.js) | User context menu | Global | `user` `guild` | `util` `embed` |\n\nThe integration types defines the contexts where the command is available, only for globally-scoped commands:\n\n| Integration Type | Description |\n| --- | --- |\n| [`user`][userctx] | The command is visible to users who have installed the application on their account. |\n| [`guild`][servctx] (Server) | The command is visible to all members of the server where the application is installed. |\n\n\u003e [!NOTE]\n\u003e Ephemeral messages are only visible to the user who invoked the interaction.\n\u003e\n\u003e ```js\n\u003e import { MessageFlags } from 'discord.js';\n\u003e export async function execute(interaction) {\n\u003e     const response = await interaction.reply({\n\u003e         content: 'Initial reply',\n\u003e         flags: MessageFlags.Ephemeral,\n\u003e         withResponse: true\n\u003e     });\n\u003e\n\u003e     // You can use `\u003cCommandInteraction\u003e.editReply` to edit the initial ephemeral reply.\n\u003e     await interaction.editReply({ content: 'The new content for the initial reply!!' });\n\u003e\n\u003e     // But `\u003cInteractionCallbackResponse\u003e.resource` is `undefined` for ephemeral replies.\n\u003e     await response.resource.message.edit({ content: 'This line will throw an error!!' });\n\u003e }\n\u003e ```\n\n\u003e [!TIP]\n\u003e Disallow a command to run in a channel where all messages are forced ephemeral:\n\u003e ```js\n\u003e import { UserError } from '@lib/error.js';\n\u003e import { PermissionFlagsBits } from 'discord.js';\n\u003e export async function execute(interaction) {\n\u003e     // If the command is invoked in a guild where the app is not installed,\n\u003e     // and the \"Use External Apps\" permission is disabled for the invoker.\n\u003e     if (\n\u003e         !interaction.appPermissions.has(PermissionFlagsBits.ViewChannel) \u0026\u0026\n\u003e         !interaction.memberPermissions.has(PermissionFlagsBits.UseExternalApps)\n\u003e     ) throw new UserError('This command cannot be invoked on this channel.');\n\u003e }\n\u003e ```\n\n\u003e [!TIP]\n\u003e To close all connections gracefully and terminate the main process:\n\u003e - Invoke the [`/eval`](src/bot/commands/chat/eval.js) slash command from within the Discord client.\n\u003e - Once the [modal][modals] or pop-up form appears, submit the following code:\n\u003e ```js\n\u003e (interaction) =\u003e {\n\u003e     // This code is evaluated in 'src/bot/bot.js'.\n\u003e     interaction.client.bot.eval(async ({ manager }) =\u003e {\n\u003e         // This code is evaluated in 'src/bot/index.js'.\n\u003e         await manager.broadcastEval(client =\u003e client.destroy());\n\u003e         process.exit(); // terminate the process (src/bot/index.js)\n\u003e     });\n\u003e }\n\u003e ```\n\n## License\n\nThis project is licensed under the **GNU General Public License v3.0**.\nSee the [license file](LICENSE) for details.\n\n\u003c!-- Footnotes --\u003e\n[^1]: [Node.js ≥24][v2340] is required for `Error.isError` and `Promise.try`.\n[^2]: [YouTube — PSA: Discord added a New Raid and Scamming Method... (@NoTextToSpeech)](https://youtu.be/6vjG34uyPz0)\n\n\u003c!-- Reference Links --\u003e\n[node]: https://nodejs.org\n[node-sqlite]: https://nodejs.org/api/sqlite.html\n[node-ipc]: https://nodejs.org/api/child_process.html#class-childprocess\n[v2250]: https://nodejs.org/en/blog/release/v22.5.0\n[v2340]: https://nodejs.org/en/blog/release/v24.0.0\n\n[pnpm]: https://pnpm.io/installation\n[sqlite]: https://sqlite.org\n\n[terminal]: https://learn.microsoft.com/en-us/windows/terminal\n\n[code]: https://code.visualstudio.com\n[code-terminal]: https://code.visualstudio.com/docs/terminal/basics\n[code-palette]: https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette\n[code-eslint]: https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint\n\n[apps]: https://discord.com/developers/applications\n[insctx]: https://discord.com/developers/docs/resources/application#installation-context\n[compv2]: https://discord.com/developers/docs/change-log/2025-04-22-components-v2 \"Components v2\"\n[compref]: https://discord.com/developers/docs/components/reference \"Component Reference\"\n[userctx]: https://discord.com/developers/docs/resources/application#user-context\n[servctx]: https://discord.com/developers/docs/resources/application#server-context\n[regcmds]: https://discord.com/developers/docs/tutorials/upgrading-to-application-commands#registering-commands\n[appcmds]: https://discord.com/developers/docs/interactions/application-commands\n\n[djs]: https://discord.js.org\n[sharding]: https://discordjs.guide/sharding\n[setup]: https://discordjs.guide/preparations/setting-up-a-bot-application.html\n[modals]: https://discordjs.guide/interactions/modals.html\n\n[clone]: https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository\n[template]: https://github.com/new?template_name=discord.js-template\u0026template_owner=flipeador\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflipeador%2Fdiscord.js-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflipeador%2Fdiscord.js-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflipeador%2Fdiscord.js-template/lists"}