Skip to content

Commit

Permalink
feat(command): add generateDashLessAliases (#146)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeroen Claassens <support@favware.tech>
  • Loading branch information
Stitch07 and favna committed Feb 1, 2021
1 parent d5e9847 commit e94649c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"dependencies": {
"@sapphire/discord-utilities": "^2.0.1",
"@sapphire/discord.js-utilities": "^1.3.1",
"@sapphire/pieces": "^1.2.0",
"@sapphire/pieces": "^1.2.1",
"@sapphire/ratelimits": "^1.1.4",
"@sapphire/utilities": "^1.4.3",
"lexure": "^0.17.0"
Expand Down
15 changes: 15 additions & 0 deletions src/lib/structures/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ export abstract class Command<T = Args> extends AliasPiece {
['「', '」'] // Corner brackets (CJK)
]
);

if (options.generateDashLessAliases) {
const dashLessAliases = [];
if (this.name.includes('-')) dashLessAliases.push(this.name.replace(/-/g, ''));
for (const alias of this.aliases) if (alias.includes('-')) dashLessAliases.push(alias.replace(/-/g, ''));

this.aliases = [...this.aliases, ...dashLessAliases];
}
}

/**
Expand Down Expand Up @@ -94,6 +102,13 @@ export abstract class Command<T = Args> extends AliasPiece {
* @since 1.0.0
*/
export interface CommandOptions extends AliasPieceOptions {
/**
* Whether to add aliases for commands with dashes in them
* @since 1.0.0
* @default false
*/
generateDashLessAliases?: boolean;

/**
* The description for the command.
* @since 1.0.0
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -753,10 +753,10 @@
resolved "https://registry.yarnpkg.com/@sapphire/eslint-config/-/eslint-config-2.1.0.tgz#bce6ad2779783d16e12b0f7f2150342ae41f291d"
integrity sha512-oTo7URwshIF3rvm17GTvnDw9cM6Ux26kYQNMMv3Q8GRMHiK33eod199vxacaKlrf8wgboszDcttYd5hctk/KNA==

"@sapphire/pieces@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@sapphire/pieces/-/pieces-1.2.0.tgz#a77f0ece618b6693ac90a4254b4e8b18ee79afbe"
integrity sha512-cwlk+iLkRLdrpXHvT3Jdn0wVHY4fQzYdomkjgUvIbIvJ8yKVWQldbWnucjzQ0q9r7KvUnjOKM/3Rp3joy1P3RQ==
"@sapphire/pieces@^1.2.1":
version "1.2.1"
resolved "https://registry.yarnpkg.com/@sapphire/pieces/-/pieces-1.2.1.tgz#ea43fae1e9377a9edca828411c3556d469f8e995"
integrity sha512-oObMXb8qHGDI8o+Ab1WbA1oN+ejbj9dHXGAZZ6HQ1QXU6XVyA2qRDDjz+F4YAZZuDNtb679FVuLL49bIz0YGiw==
dependencies:
"@discordjs/collection" "^0.1.6"

Expand Down

0 comments on commit e94649c

Please sign in to comment.