{"id":15021682,"url":"https://github.com/joaoscoelho/djs-args","last_synced_at":"2026-03-09T12:37:07.555Z","repository":{"id":45100370,"uuid":"438582449","full_name":"JoaoSCoelho/djs-args","owner":"JoaoSCoelho","description":"A library that allows you to ask the user for specific arguments/parameters when executing some command, based on discord options for slash commands, but adapted and improved for message commands","archived":false,"fork":false,"pushed_at":"2023-07-28T20:14:18.000Z","size":130,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-18T00:12:19.891Z","etag":null,"topics":["bot","discord","discord-js","discord-js-bot"],"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/JoaoSCoelho.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":"2021-12-15T10:10:03.000Z","updated_at":"2024-01-25T10:36:43.000Z","dependencies_parsed_at":"2024-09-29T06:16:34.471Z","dependency_job_id":null,"html_url":"https://github.com/JoaoSCoelho/djs-args","commit_stats":{"total_commits":25,"total_committers":2,"mean_commits":12.5,"dds":"0.040000000000000036","last_synced_commit":"1da5e1e2919453806901ffdc271e941d349b993f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoaoSCoelho%2Fdjs-args","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoaoSCoelho%2Fdjs-args/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoaoSCoelho%2Fdjs-args/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JoaoSCoelho%2Fdjs-args/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JoaoSCoelho","download_url":"https://codeload.github.com/JoaoSCoelho/djs-args/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243012662,"owners_count":20221606,"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","discord-js","discord-js-bot"],"created_at":"2024-09-24T19:56:54.007Z","updated_at":"2026-03-09T12:37:07.523Z","avatar_url":"https://github.com/JoaoSCoelho.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# djs-args\nA library that allows you to ask the user for specific arguments/parameters when executing some command, based on discord `options` for slash commands, but adapted and improved for message commands\n\n***ENGLISH VERSION OF THE README IS INCOMPLETE, YOU CAN SEE THE PORTUGUESE VERSION [HERE](./README.pt.md)***\n\n[README em Português](/README.pt.md)\n\n## Installation\n\n```bash\n$ npm install djs-args\n```\nor\n```bash\n$ yarn add djs-args\n```\n\n## Getting Started\n\n### For Class commands\n\n```ts\n// In your BaseCommand class\n\nimport OptionsCommand, { OptionsCommandProps } from 'djs-args';\nimport { Message, Client } from 'discord.js'\n\ninterface MyCommandProps {\n  // Here you can add your own properties, like \"name\", \"description\", etc.\n}\n\nexport default abstract class BaseCommand extends OptionsCommand {\n  constructor(props: MyCommandProps \u0026 OptionsCommandProps) {\n    super(props)\n  }\n\n  abstract run(message: Message, client: Client): void\n\n  // Method that will be directly called by the \"messageCreate\" event\n  async exec(\n    message: Message,\n    client: Client,\n    usedPrefix: string,\n    usedCommand: string\n  ) {\n    // Execute the checkOptions method, which will return a Promise\n    this.checkOptions({ message, client, prefix: usedPrefix, usedCommand })\n      .then(() =\u003e {\n        // Here you execute the especific command function, like this:\n        this.run(message, client)\n      })\n      .catch((error) =\u003e {\n        //   ^^^^^ This error is a \"OptionsError\"\n        // Here you can handle the error, like this:\n        console.error(error)\n        message.reply(error.message)\n      })\n  }\n}\n```\n\n```ts\n// In your command file\n\nimport { Message, User } from 'discord.js'\n\nexport default class AvatarCommand extends BaseCommand {\n  constructor() {\n    super({\n      optionsSplit: null,\n      // ^^^^^^^^^\n      // Arguments divider by default is \"/ +/g\" (no quotes), which means that all user message content after the prefix and command name will be separated by each one or more spaces.\n      // Ex: message.content = '!avatar josh sacary';\n      // The array of options values will look like this:\n      // ['josh', 'sacary']\n      // You can change this value or make it null if you don't want to separate (in which case your command may only require one option)\n\n      options: [\n        {\n          name: 'user',\n          description: 'The user to get the avatar from',\n          type: 'USER', // Define the type of value\n          required: false, \n          caseSensitive: false, // Define if the value is case sensitive or not\n          fetch: true, // Defines whether, in case the user sends an ID, it will fetch the entire Discord or fetch only the bot users\n          matchBy: ['ID', 'MENTION', 'NICKNAME', 'TAG', 'USERNAME'],\n          matchIncluding: true,\n          onlyThisGuild: false,\n        },\n      ],\n    })\n  }\n\n  async run(message: Message) {\n    const user = (this.options[0].value as User | undefined) || message.author\n\n    message.reply(\n      `The avatar of ${user.username} is: ${user.displayAvatarURL({\n        size: 2048,\n        dynamic: true,\n      })}`\n    )\n  }\n}\n```\n\n## Options types\n\n### BOOLEAN type\n\n| Property      | Type        | Default                                                    | Optional | Description                                                                                                                                                                                                                                                                                                                                                                               |\n|---------------|-------------|------------------------------------------------------------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| type          | `'BOOLEAN'` |                                                            | \u0026times;  | The type of option you want the user to input                                                                                                                                                                                                                                                                                                                                             |\n| description   | `string`    |                                                            | \u0026times;  | Description of what the option means                                                                                                                                                                                                                                                                                                                                                      |\n| name          | `string`    |                                                            | \u0026times;  | The name of the option                                                                                                                                                                                                                                                                                                                                                                    |\n| caseSensitive | `boolean`   | `false`                                                    | \u0026check;  | Defines whether what the user enters should also be compared in relation to the case of letters.\u003cbr\u003eIf set to `caseSensitive: false`, the input `True` will be considered a valid input of true value.\u003cbr\u003eIf set to `caseSensitive: true`, the input `True` will be considered an invalid input (unless there is one aliase equals `True`) and will return an error which may be treated. |\n| falsyAliases  | `string[]`  | `['false', 'f', '0', 'n', 'no', 'nao', 'não', 'falso']`    | \u0026check;  | Defines the values that will be considered and treated as `false` if the user types it.\u003cbr\u003eMaybe you don't want to leave the default values behind, so you can add new ones without losing the defaults like this:\u003cbr\u003e`falsyAliases: [...OptionsCommand.defaultFalsyAliases, ...newFalsyAliases]`                                                                                         |\n| truthyAliases | `string[]`  | `['true', 't', '1', 'y', 'yes', 'sim', 's', 'verdadeiro']` | \u0026check;  | Set the values that will be considered and treated as `true` if the user types it.\u003cbr\u003eMaybe you don't want to leave the default values behind, so you can add new ones without losing the defaults like this:\u003cbr\u003e`truthyAliases: [...OptionsCommand.defaultTruthyAliases, ...newTruthyAliases]`                                                                                           |\n| required      | `boolean`   | `false`                                                    | \u0026check;  | Defines if the user needs to put any value for this option.                                                                                                                                                                                                                                                                                                                         |\n| value         | `boolean`   | `undefined`                                                | \u0026check;  | Sets a default value for the option.\u003cbr\u003eIt is through this property that you will look for the value that the user typed.\u003cbr\u003eNOTE: Does not work if `required: true`                                                                                                                                 |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoaoscoelho%2Fdjs-args","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoaoscoelho%2Fdjs-args","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoaoscoelho%2Fdjs-args/lists"}