{"id":22179971,"url":"https://github.com/iepog/commandhandler","last_synced_at":"2025-03-24T18:44:44.377Z","repository":{"id":57204103,"uuid":"417582127","full_name":"iEpog/commandhandler","owner":"iEpog","description":"Very simple but very useful command handler. ","archived":false,"fork":false,"pushed_at":"2021-10-16T00:31:25.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-19T11:41:42.102Z","etag":null,"topics":["command","command-handler","command-handlers","discord-js","discord-js-example","discordjs","epog","file-handler","file-handling","filehandle","filehandler","filehandling","filesystem","iepog","javascript","node-js","node-module","nodejs","nodejs-example"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iEpog.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-15T17:25:57.000Z","updated_at":"2021-10-16T00:31:28.000Z","dependencies_parsed_at":"2022-09-17T18:12:16.621Z","dependency_job_id":null,"html_url":"https://github.com/iEpog/commandhandler","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/iEpog%2Fcommandhandler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iEpog%2Fcommandhandler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iEpog%2Fcommandhandler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iEpog%2Fcommandhandler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iEpog","download_url":"https://codeload.github.com/iEpog/commandhandler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245331083,"owners_count":20597895,"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":["command","command-handler","command-handlers","discord-js","discord-js-example","discordjs","epog","file-handler","file-handling","filehandle","filehandler","filehandling","filesystem","iepog","javascript","node-js","node-module","nodejs","nodejs-example"],"created_at":"2024-12-02T09:16:15.830Z","updated_at":"2025-03-24T18:44:44.346Z","avatar_url":"https://github.com/iEpog.png","language":"JavaScript","readme":"# commandhandler\nVery simple but very useful command handler. \n\n\u003ch1\u003eInstallation\u003c/h1\u003e\n\nTo install the node-module\n\n``\nnpm install commandhandler.js\n``\n\nCode:\n```js\nlet ch = new (require('commandhandler.js'))();\n```\n\n\u003ch1\u003eMethods\u003c/h1\u003e\n\n - `.init(path, extension)`\n ```js \n//Gets all commands on specified path then initialize all files if file extension correct \n```\n - `.has(commandName)`\n ```js \n //Checks if command exist. If Exist: returns command. If not Exits returns false\n ```\n - `.get()`\n  ```js \n // Returns all initialized files\n ```\n - `.files`\n ```js \n // Returns all initialized files\n ```\n - `.path` \n ```js \n // Returns folder path\n ```\n \n\u003ch1\u003eExample (with a \u003ca href=\"https://discord.js.org/\"\u003eDiscord.js\u003c/a\u003e) \u003c/h1\u003e\n\n``Main File:``\n\n```js\nlet ch = new (require('commandhandler.js'))();\n\nlet Discord= require('discord.js');\nlet client = new Discord.Client();\n\nlet prefix = \"+\";\n\nclient.on('ready',()=\u003econsole.log('Bot Ready'));\n\n\nclient.on('message', (message) =\u003e {\n   if(message.author.bot) return;\n   if (!message.content.startsWith(prefix)) return;\n   const args = message.content.slice().trim().split(/ +/g);\n   let cmd = ch.has(args.shift().slice(prefix.length).toLowerCase());\n   if (cmd) cmd(client, message, args);\n});\n\nclient.login(\"YOUR BOT TOKEN\");\n\nch.init(__dirname+'/commands/','.js');\n```\n\n``./commands/say.js``\n\n```js\nexports.run = (client,message,args) =\u003e {\n    message.channel.send('['+message.author.tag+ ']: ' +args.join(' '));\n\n}\n\nexports.name= \"say\"; \n```\n\n\n\u003ch1\u003eExample 2\u003c/h1\u003e\n\n ``Main File:``\n\n~~~ js\nlet ch = new (require('commandhandler.js'))();\n\nch.on('ready',()=\u003e{\n\n   console.log('Command handler are initialized');\n   \n     console.log('All Files: ',ch.files,'Running \"log.js\" ');\n     ch.files.log('./log.txt', '['+Date.now()+'] Test Function Working!');\n     \n});\n\n\nch.init(__dirname+'/commands/','.js');\n~~~\n\n ``./commands/log.js:``\n\n~~~ js\nlet fs =require('fs');\n\nexports.run = (path,data) =\u003e {\n\n    fs.writeFileSync(path, data+'\\n', { flag: 'a' });\n    \n    let file =fs.readFileSync(path).toString();\n    \n    if(!file) file= data;\n    \n    return file;\n};\n\nexports.name= \"log\";\n~~~\n\nThen look at the log.txt file:\n~~~\n[1634320812437] Test Function Working!\n[1634320817816] Test Function Working!\n[1634320819018] Test Function Working!\n[1634320819813] Test Function Working!\n~~~\nIt works\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiepog%2Fcommandhandler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiepog%2Fcommandhandler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiepog%2Fcommandhandler/lists"}