{"id":15211460,"url":"https://github.com/supportmailapp/djsCommandHelper","last_synced_at":"2025-10-29T21:30:40.764Z","repository":{"id":248330997,"uuid":"828399269","full_name":"The-LukeZ/djsCommandHelper","owner":"The-LukeZ","description":"Deploys your bot's commands with some new configuration options - simple and easy while only using REST.","archived":false,"fork":false,"pushed_at":"2024-11-05T20:51:29.000Z","size":6098,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-11T13:05:37.531Z","etag":null,"topics":["commandhandler","commands","discord","discord-js","discordjs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/The-LukeZ.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":"2024-07-14T03:08:56.000Z","updated_at":"2024-11-05T20:51:32.000Z","dependencies_parsed_at":"2024-07-17T01:25:56.358Z","dependency_job_id":"60a22653-30fb-4b55-87ed-8f02523c41fa","html_url":"https://github.com/The-LukeZ/djsCommandHelper","commit_stats":null,"previous_names":["the-lukez/djscommanddeployer","the-lukez/djscommandhelper"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/The-LukeZ%2FdjsCommandHelper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/The-LukeZ%2FdjsCommandHelper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/The-LukeZ%2FdjsCommandHelper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/The-LukeZ%2FdjsCommandHelper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/The-LukeZ","download_url":"https://codeload.github.com/The-LukeZ/djsCommandHelper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238892293,"owners_count":19548166,"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":["commandhandler","commands","discord","discord-js","discordjs"],"created_at":"2024-09-28T08:41:32.991Z","updated_at":"2025-10-29T21:30:40.423Z","avatar_url":"https://github.com/The-LukeZ.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# djsCommandHelper\n\nA simple, easy to use module that houses functions to can refresh global and guild specific commands for your Discord App.\n\n## Installation\n\n```bash\nnpm install git+ssh://git@github.com:The-LukeZ/djsCommandHelper.git\nnpm install djs-command-helper\n```\n\n## Usage\n\n#### Folder structure\n\n_The `src` folder it can be any folder. Just the `commands` folder should be a subfolder of the directory your `index.js` is located in._\n\n**Example:**\n\n```\n📂src\n ┣ 📄index.js\n ┗ 📂commands\n   ┗📂utility\n     ┣ 📄ping.js\n     ┗ 📄your-private-command.js\n```\n\n#### The command file\n\n\u003e **Note that for using this you need to install [discord.js](https://discordjs.guide/)!**\n\n\u003cdetails\u003e\n\u003csummary\u003eFields in the command file (Click to expand)\u003c/summary\u003e\n\n| Key name | Description                                                                                               | Default |\n| -------- | --------------------------------------------------------------------------------------------------------- | ------- |\n| ignore   | If set to `true` then this command will be ignored upon refreshing                                        | `false` |\n| guildIds | An Array of guild ids in which the command should be registered/updated ; command is global if not set    | []      |\n| data     | The raw command data [Learn more about it here](https://discordjs.guide/creating-your-bot/slash-commands) | `-`     |\n| run      | The function to call (It's only important for your own logic - so name this whatever you want)            | `-`     |\n\n`-` means that it doesn't have a default value\n\n\u003c/details\u003e\n\n```js\nconst { SlashCommandBuilder } = require(\"discord.js\");\n\nmodule.exports = {\n    ignore: true,\n    guildIds: [\"123456789\", \"987654321\"], // Note: This wont automatically delete them from guilds!\n    data: new SlashCommandBuilder()\n        .setName(\"ping\")\n        .setDescription(\"Replies with Pong!\"),\n\n    // The function to call whenever the command is executed (Doesnt matter when calling client.deployCommands())\n    async run(interaction) {\n        await interaction.reply(\"Pong!\");\n    },\n};\n```\n\n### Deploy the commands\n\n```js\n// Don't forget to load all things from discord.js\n\nconst { deployCommands } = require(\"djs-command-deployer\");\nconst path = require(\"node:path\");\nrequire(\"dotenv\").config(); // load your token and app's id\n\n// Set up your client\n// Use the guide as an example if you need help\n// https://discordjs.guide/creating-your-bot/main-file\n\n// When the client is ready, run this code once.\nclient.once(Events.ClientReady, (readyClient) =\u003e {\n    console.log(`Ready! Logged in as ${readyClient.user.tag}`);\n\n    // Call deployCommands to refresh your commands\n    deployCommands(\n        path.join(__dirname, \"commands\", \"utility\")\n        {\n            appToken: process.env.DISCORD_TOKEN,\n            appId: process.env.ClientId,\n        }\n        // logs are optional\n    );\n});\n\n// Log in to Discord with your client's token\nclient.login(process.env.DISCORD_TOKEN);\n```\n\n### Delete a guild-command\n\nGlobal commands can be automatically deleted if you just delete the file or set `ignore: true` and run the `deployCommands` function again.\n\nGuild commands on the other hand need to be deleted manually.\n\nThe name of a command of an application is unique, but only in its type. Command ids are unique.\nMake sure that you have command's id and not it's name.\n\nYou can get the command id by either typing in the command and then right click the description above or by giong into the guild settings \u003e Integrations \u003e YOUR_BOT \u003e right mouse click on the command \u003e **Copy Command ID**\n\nIn this example we are building a manager-command that has StringOptions for the command and the guild id where one can paste in the ID or the name.\n\n````js\nconst { SlashCommandBuilder, EmbedBuilder } = require(\"discord.js\");\nconst { deleteCommand } = require(\"djs-command-helper\");\n\nmodule.exports = {\n    guildIds: [\"12345\"], // the guild id of the dev's guild so that no one can delete every command\n    data: new SlashCommandBuilder()\n        .setName(\"manage-commands\")\n        .setDescription(\"Replies with Pong!\")\n        .addStringOption((op) =\u003e\n            op\n                .setName(\"command-id\")\n                .setDescription(\"The ID of the command to be removed\")\n        )\n        .addStringOption((op) =\u003e\n            op\n                .setName(\"server-id\")\n                .setDescription(\n                    \"The ID of the server from which the command is to be removed\"\n                )\n        ),\n\n    // This function is called whenever an interactionCreate event is triggered.\n    async run(interaction) {\n        const guildId = interaction.options.getString(\"server-id\");\n        const command = interaction.options.getString(\"command-id\");\n        await interaction.deferReply({ ephemeral: true }); // Defer to remove the risk of not responding in time\n\n        try {\n            const response = await deleteCommand(command, {\n                appToken: interaction.client.token,\n                appId: interaction.application.id,\n                guildId: guildId,\n            });\n        } catch (err) {\n            // respond with an error if the operation fails in some way\n            return await interaction.editReply({\n                embeds: [\n                    new EmbedBuilder()\n                        .setTitle(\"❌ Command not deleted due to an error\")\n                        .setDescription(\"```\" + err + \"```\")\n                        .setColor(0xff0000),\n                ],\n            });\n        }\n\n        // Success!\n        await interaction.editReply({\n            embeds: [\n                new EmbedBuilder()\n                    .setTitle(\"✅ Command deleted\")\n                    .setColor(0x44ff44),\n            ],\n        });\n    },\n};\n````\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsupportmailapp%2FdjsCommandHelper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsupportmailapp%2FdjsCommandHelper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsupportmailapp%2FdjsCommandHelper/lists"}