{"id":25975773,"url":"https://github.com/miguelmikkey/discord-bot-template","last_synced_at":"2025-03-05T03:24:03.199Z","repository":{"id":277564889,"uuid":"932788188","full_name":"miguelmikkey/discord-bot-template","owner":"miguelmikkey","description":"A template for your Discord bot; this is my personal template. This is the template I use when starting a new bot.","archived":false,"fork":false,"pushed_at":"2025-03-04T04:58:15.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-04T05:24:49.138Z","etag":null,"topics":["bot","discord","discordjs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/miguelmikkey.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}},"created_at":"2025-02-14T14:21:53.000Z","updated_at":"2025-03-04T04:58:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"b1651120-d44a-45c2-a199-ed78659dca10","html_url":"https://github.com/miguelmikkey/discord-bot-template","commit_stats":null,"previous_names":["miguelmikkey/discord-bot-template"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miguelmikkey%2Fdiscord-bot-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miguelmikkey%2Fdiscord-bot-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miguelmikkey%2Fdiscord-bot-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miguelmikkey%2Fdiscord-bot-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miguelmikkey","download_url":"https://codeload.github.com/miguelmikkey/discord-bot-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241956604,"owners_count":20048666,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","discord","discordjs"],"created_at":"2025-03-05T03:24:02.741Z","updated_at":"2025-03-05T03:24:03.180Z","avatar_url":"https://github.com/miguelmikkey.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Discord bot 🤖 template for DiscordJS bots\n\nThis repository contains a basic template for creating Discord bots using `discord.js`, `pm2` for process management and `.env` for environment variable configuration.\n\n## Features\n\n- **Basic structure** to start your own project.\n- [**Discord.js**](https://discord.js.org/): Library to interact with the Discord API.\n- [**PM2**](https://pm2.keymetrics.io/): Process manager for Node.js applications, making it easy to run and monitor your bot.\n- [**.env**](https://www.npmjs.com/package/dotenv): Environment variable file to securely manage configuration settings.\n- [**Discord notification ErrorHandler**](#errorhandler-example-i-find-this-very-useful-for-production): Sometimes you may encounter errors after deploying your bot; that's why I usually link `error handlers` to a channel in a personal Discord server so I can get notified.\u003cbr\u003e\n- [**locales**](#-locales-add-multiple-languages-to-your-bot) folder. Theres nothing like supporting multiple languages if you want your bot to be popular, more information about how to use this below.\n\n## ErrorHandler example (_I find this very useful for production_)\n\n\u003cimg src=\"https://i.imgur.com/LZoe93x.png\"\u003e\n\n## Prerequisites\n\n- Node.js (version 14 or later)\n- PM2 (install globally using `npm install pm2 -g`)\n\n## Installation\n\n### 1. **Clone the repository:**\n\n```bash\ngit clone https://github.com/miguelmikkey/discord-bot-template.git\ncd discord-bot-template\n```\n\n### 2. Install dependencies:\n\nBy default, npm install will install all modules listed as dependencies in package\n\n```console\nnpm install\n```\n\n### 3. Set up environment variables:\n\nRename `.env.example` to `.env` file in the root directory of the project and add your configuration settings:\n\n```.env\n# General variables\nDISCORD_TOKEN=your_discord_bot_token\nCLIENT_ID=your_bot_id\nDEV_GUILD_ID=your_dev_guild_id # For command propagation purposes\n\n# Optional variables\nERROR_HANDLER_MENTION_ID=the_role_you_want_to_be_mentioned\nERROR_HANDLER_CHANNEL_ID=your_error_handler_channel_id # Role ID\nGUILD_ID=your_guild_id # For error handler purposes\n```\n\n## Usage\n\n- **Commands:** Customize the bot commands in the commands directory.\n- **Events:** Handle Discord events in the events directory.\n- **Database:** Use the models directory to define your MongoDB schemas.\n- **Error handler channel:** `uncaughtException` and `unhandledRejection` will be notified in your personal `discord-channel`\n\n  ## Example commands:\n\n- `/testButton` \u003cbr\u003e\n  \u003cimg src=\"https://i.imgur.com/TK2f5eW.png\"\u003e\n- `/testModal` \u003cbr\u003e\n  \u003cimg src=\"https://i.imgur.com/jGcKKAQ.png\"\u003e\n- `/testSelect` \u003cbr\u003e\n  \u003cimg src=\"https://i.imgur.com/3kuYbMz.png\"\u003e\n\n## 📁 locales (`Add multiple languages to your bot`)\n\nThe variables you will have to use around your code:\n\n- `t`: This will import the translate function from `translate.js`\n- `locale`: This will detect the server's preferred language. **Note that this only works if the server has the Community feature enabled**; otherwise, it defaults to `en_US`. You can modify this behavior as needed, such as by adding an option for users to switch between languages.\n\n### Example:\n\n```js\nconst t = require(\"./src/utils/translate\");\nconst locale = guild.preferredLocale || \"en_US\";\n\nconst embed = new EmbedBuilder()\n  .setTitle(t(locale, \"embeds.exampleTitle\"))\n  .setDescription(\n    t(locale, \"embeds.exampleDescription\", {\n      userID: interaction.user.id,\n    })\n  );\n```\n\n```json\n// .JSON file (/locales/en_US.json)\n{\n  \"embeds\": {\n    \"exampleTitle\": \"This is a title\",\n    \"exampleDescription\": \"Hey \u003c@{userID}\u003e, this is a description!\"\n  }\n}\n```\n\n```json\n// .JSON file (/locales/es_ES.json)\n{\n  \"embeds\": {\n    \"exampleTitle\": \"Esto es un título.\",\n    \"exampleDescription\": \"Hey \u003c@{userID}\u003e, esto es una descripción!\"\n  }\n}\n```\n\nIn this example, if the embed is triggered in a server where \"English\" is selected as the preferred language, it will use the first option (`en_US`) for translation. However, if \"Spanish\" is selected, it will use `es_ES` instead. If there is no `es_ES` file available, it will default to `en_US`.\n\n### Example with the `/testButton` command.\n\n\u003cimg src=\"https://i.imgur.com/dynX26p_d.webp?maxwidth=760\u0026fidelity=grand\"\u003e\n\n## Dependencies\n\n- `discord.js`: For interacting with the Discord API.\n- `dotenv`: For loading environment variables from a .env file.\n- `pm2`: For process management.\n\n## Contributing\n\n\u003e [!NOTE]\n\u003e **¡Im a Trainee**\n\u003e Any help or TIPs are welcome. Keep in mind that this is just a template for general-purpose bots; it has to be versatile , efficient, and lightweight. With that said , feel free to fork this repository and submit pull requests. **Contributions are welcome!** :D\n## License\n\nThis project is licensed under the [MIT](https://github.com/miguelmikkey/discord-bot-template/blob/main/LICENSE) License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiguelmikkey%2Fdiscord-bot-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiguelmikkey%2Fdiscord-bot-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiguelmikkey%2Fdiscord-bot-template/lists"}