{"id":22166230,"url":"https://github.com/maxerbox/command-loader-fisherman","last_synced_at":"2025-03-24T16:15:32.773Z","repository":{"id":57204035,"uuid":"104249915","full_name":"maxerbox/command-loader-fisherman","owner":"maxerbox","description":"Fisherman middleware that load command from files to fisherman","archived":false,"fork":false,"pushed_at":"2017-09-23T18:25:53.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T07:54:12.782Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maxerbox.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}},"created_at":"2017-09-20T17:58:42.000Z","updated_at":"2017-09-20T18:19:22.000Z","dependencies_parsed_at":"2022-09-17T19:12:09.142Z","dependency_job_id":null,"html_url":"https://github.com/maxerbox/command-loader-fisherman","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxerbox%2Fcommand-loader-fisherman","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxerbox%2Fcommand-loader-fisherman/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxerbox%2Fcommand-loader-fisherman/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxerbox%2Fcommand-loader-fisherman/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxerbox","download_url":"https://codeload.github.com/maxerbox/command-loader-fisherman/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245304869,"owners_count":20593626,"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":[],"created_at":"2024-12-02T05:18:34.194Z","updated_at":"2025-03-24T16:15:32.753Z","avatar_url":"https://github.com/maxerbox.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fisherman Command Loader\n\n\u003eLoads commands from files in a directory\n\n## Set up\n\n```bash\nnpm install --save command-loader-fisherman\n```\n\nInclude the middleware to the bot:\n\n```javascript\n[...]\nconst CommandLoader = require('command-loader-fisherman')\nvar commandLoader = new CommandLoader(path.resolve(__dirname, 'commands')) //the  command dir\nbot.use(commandLoader)\n[...]\n```\n\n## Adding commands\n\nAs you can see, you initialize the CommandLoader with a directory, **use path.resolve() to get the full path directory** location (since `fs.stat()` is used).\n\nCommands are loaded once you initialize middlewares with fisherman.\n\nEach commands should be in a subfolder, named like the register name.\n**A `_register.json` as to be present in each register directory**\n\nTree example (C = commands folder):\n\n```bash\nC:\n├───core\n│       help.js\n│       _register.json\n│\n└───giveaways\n        giveaway.js\n        _register.json\n```\n\nEach javascript file inside will be loaded, which should contains a exported command object\n\n### Javascript command file\n\nYou just have to export a command object, like this:\n\nExample: help command (named `help.js`, in core dir)\n\n```javascript\nvar helpMessageBuilt = null\nmodule.exports = {\n  name: 'help',\n  execute: function (req, res) {\n    if (helpMessageBuilt) {\n      res.send('', { embed: helpMessageBuilt }).catch(console.log)\n      return\n    }\n    var embed = { title: 'Bot help' }\n    var description = ''\n    var commands\n    req.client.registers.forEach(function (register) {\n      commands = ''\n      register.forEach(function (value) {\n        commands = commands + ' `' + value.name + '` '\n      })\n      description = description + '__' + register.name + ':__\\n' + commands + '\\n\\n'\n    })\n\n    embed.description = description\n    helpMessageBuilt = embed\n    res.send('', { embed: helpMessageBuilt }).catch(console.log)\n  },\n  channelType: ['dm', 'text']\n\n}\n```\n\n### _register.json file\n\nThis file contain register properties, **it has to appear in each register directory**:\n\nThere are only 3 properties:\n\n| Name        | Description         |\n| ------------- |:-------------:|\n| key     | Register key name (used in register map of fisherman) |\n| name      | Register name     |\n| description | Register description     |\n\n*All those property have default value = `null`*\n\nExample:\n\n```json\n{\n    \"key\": \"fun\",\n    \"name\": \"fun\",\n    \"description\": \"commands for user fun time\"\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxerbox%2Fcommand-loader-fisherman","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxerbox%2Fcommand-loader-fisherman","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxerbox%2Fcommand-loader-fisherman/lists"}