{"id":17277792,"url":"https://github.com/issadarkthing/commandment","last_synced_at":"2025-03-26T14:20:02.278Z","repository":{"id":57121293,"uuid":"403483427","full_name":"issadarkthing/commandment","owner":"issadarkthing","description":"Lightweight discord.js command handling framework","archived":false,"fork":false,"pushed_at":"2022-06-30T12:57:40.000Z","size":397,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-02T11:45:02.753Z","etag":null,"topics":["discord-js"],"latest_commit_sha":null,"homepage":"commandment.vercel.app","language":"HTML","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/issadarkthing.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":"2021-09-06T04:21:50.000Z","updated_at":"2022-09-27T00:27:55.000Z","dependencies_parsed_at":"2022-08-24T05:11:15.984Z","dependency_job_id":null,"html_url":"https://github.com/issadarkthing/commandment","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/issadarkthing%2Fcommandment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/issadarkthing%2Fcommandment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/issadarkthing%2Fcommandment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/issadarkthing%2Fcommandment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/issadarkthing","download_url":"https://codeload.github.com/issadarkthing/commandment/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245668641,"owners_count":20653008,"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":["discord-js"],"created_at":"2024-10-15T09:09:58.743Z","updated_at":"2025-03-26T14:20:02.256Z","avatar_url":"https://github.com/issadarkthing.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Commandment\nSimple [discord.js](https://discord.js.org/#/) command framework.\n\n\n## Why\nBecause I find myself repeating over and over again doing command handling. This\nlibrary will certainly reduce the development time with powerful command\nhandling for the bot.\n\n## Features\n- one command per file\n- multiple instance blocking i.e. prevent user from running the same command\n  while the other command is still running\n- lightweight\n- easy to use\n- command throttling\n\n## Installing\n```sh\n$ npm install @jiman24/commandment\n```\n\n## Documentation\nYou can read about the documentation [here](https://commandment.vercel.app/)\n\n## Example\n`index.ts`\n```ts\nimport { Client } from \"discord.js\";\nimport { CommandManager } from \"../index\";\nimport path from \"path\";\n\nconst COMMAND_PREFIX = \"!\";\nconst client = new Client({ intents: [\"GUILDS\", \"GUILD_MESSAGES\"] });\nconst commandManager = new CommandManager(COMMAND_PREFIX);\n\ncommandManager.verbose = true;\ncommandManager.registerCommands(path.resolve(__dirname, \"./commands\"));\n\ncommandManager.registerCommandNotFoundHandler((msg, cmdName) =\u003e {\n  msg.channel.send(`Cannot find command \"${cmdName}\"`);\n})\n\ncommandManager.registerCommandOnThrottleHandler((msg, cmd, timeLeft) =\u003e {\n  const time = (timeLeft / 1000).toFixed(2);\n  msg.channel.send(`You cannot run ${cmd.name} command after ${time} s`);\n})\n\nclient.on(\"ready\", () =\u003e console.log(client.user?.username, \"is ready!\"))\nclient.on(\"messageCreate\", msg =\u003e commandManager.handleMessage(msg));\n\nclient.login(process.env.BOT_TOKEN);\n```\n\n`commands/Ping.ts`\n```ts\nimport { Message } from \"discord.js\";\nimport { Command } from \"../../index\";\n\nexport default class extends Command {\n  name = \"ping\";\n  aliases = [\"p\"];\n  throttle = 10 * 1000; // 10 seconds\n\n  exec(msg: Message, args: string[]) {\n    msg.channel.send(\"pong\");\n  }\n}\n```\n\n`commands/Wait.ts`\n```ts\nimport { Message } from \"discord.js\";\nimport { Command } from \"../../index\";\n\nexport default class extends Command {\n  name = \"wait\";\n  block = true;\n\n  private sleep(ms: number) {\n    return new Promise((resolve) =\u003e {\n      setTimeout(resolve, ms);\n    })\n  }\n\n  async exec(msg: Message, args: string[]) {\n    msg.channel.sendTyping();\n    const [ms] = args;\n\n    await this.sleep(parseInt(ms))\n    msg.channel.send(\"done\");\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fissadarkthing%2Fcommandment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fissadarkthing%2Fcommandment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fissadarkthing%2Fcommandment/lists"}