diff --git a/package.json b/package.json index 10612d442..d1dee096e 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/lib/structures/Command.ts b/src/lib/structures/Command.ts index 6eedc29be..501fa5b4e 100644 --- a/src/lib/structures/Command.ts +++ b/src/lib/structures/Command.ts @@ -56,6 +56,14 @@ export abstract class Command 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]; + } } /** @@ -94,6 +102,13 @@ export abstract class Command 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 diff --git a/yarn.lock b/yarn.lock index 6cc47f7ef..eaae93539 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"