UNPKG

@sapphire/framework

Version:

Discord bot framework built for advanced and amazing bots.

1 lines 3.1 kB
{"version":3,"file":"minMaxLength.mjs","names":[],"sources":["../../../../../../../src/lib/utils/application-commands/compute-differences/option/minMaxLength.ts"],"sourcesContent":["import type { APIApplicationCommandStringOption } from 'discord-api-types/v10';\nimport type { CommandDifference } from '../_shared';\n\nexport function* handleMinMaxLengthOptions({\n\tcurrentIndex,\n\texistingOption,\n\texpectedOption,\n\tkeyPath\n}: {\n\tcurrentIndex: number;\n\tkeyPath: (index: number) => string;\n\texpectedOption: APIApplicationCommandStringOption;\n\texistingOption: APIApplicationCommandStringOption;\n}): Generator<CommandDifference> {\n\t// 0. No min_length and now we have min_length\n\tif (existingOption.min_length === undefined && expectedOption.min_length !== undefined) {\n\t\tyield {\n\t\t\tkey: `${keyPath(currentIndex)}.min_length`,\n\t\t\texpected: 'min_length present',\n\t\t\toriginal: 'no min_length present'\n\t\t};\n\t}\n\t// 1. Have min_length and now we don't\n\telse if (existingOption.min_length !== undefined && expectedOption.min_length === undefined) {\n\t\tyield {\n\t\t\tkey: `${keyPath(currentIndex)}.min_length`,\n\t\t\texpected: 'no min_length present',\n\t\t\toriginal: 'min_length present'\n\t\t};\n\t}\n\t// 2. Equality check\n\telse if (existingOption.min_length !== expectedOption.min_length) {\n\t\tyield {\n\t\t\tkey: `${keyPath(currentIndex)}.min_length`,\n\t\t\toriginal: String(existingOption.min_length),\n\t\t\texpected: String(expectedOption.min_length)\n\t\t};\n\t}\n\n\t// 0. No max_length and now we have max_length\n\tif (existingOption.max_length === undefined && expectedOption.max_length !== undefined) {\n\t\tyield {\n\t\t\tkey: `${keyPath(currentIndex)}.max_length`,\n\t\t\texpected: 'max_length present',\n\t\t\toriginal: 'no max_length present'\n\t\t};\n\t}\n\t// 1. Have max_length and now we don't\n\telse if (existingOption.max_length !== undefined && expectedOption.max_length === undefined) {\n\t\tyield {\n\t\t\tkey: `${keyPath(currentIndex)}.max_length`,\n\t\t\texpected: 'no max_length present',\n\t\t\toriginal: 'max_length present'\n\t\t};\n\t}\n\t// 2. Equality check\n\telse if (existingOption.max_length !== expectedOption.max_length) {\n\t\tyield {\n\t\t\tkey: `${keyPath(currentIndex)}.max_length`,\n\t\t\toriginal: String(existingOption.max_length),\n\t\t\texpected: String(expectedOption.max_length)\n\t\t};\n\t}\n}\n"],"mappings":";AAGA,UAAiB,0BAA0B,EAC1C,cACA,gBACA,gBACA,WAMgC;AAEhC,KAAI,eAAe,eAAe,UAAa,eAAe,eAAe,OAC5E,OAAM;EACL,KAAK,GAAG,QAAQ,aAAa,CAAC;EAC9B,UAAU;EACV,UAAU;EACV;UAGO,eAAe,eAAe,UAAa,eAAe,eAAe,OACjF,OAAM;EACL,KAAK,GAAG,QAAQ,aAAa,CAAC;EAC9B,UAAU;EACV,UAAU;EACV;UAGO,eAAe,eAAe,eAAe,WACrD,OAAM;EACL,KAAK,GAAG,QAAQ,aAAa,CAAC;EAC9B,UAAU,OAAO,eAAe,WAAW;EAC3C,UAAU,OAAO,eAAe,WAAW;EAC3C;AAIF,KAAI,eAAe,eAAe,UAAa,eAAe,eAAe,OAC5E,OAAM;EACL,KAAK,GAAG,QAAQ,aAAa,CAAC;EAC9B,UAAU;EACV,UAAU;EACV;UAGO,eAAe,eAAe,UAAa,eAAe,eAAe,OACjF,OAAM;EACL,KAAK,GAAG,QAAQ,aAAa,CAAC;EAC9B,UAAU;EACV,UAAU;EACV;UAGO,eAAe,eAAe,eAAe,WACrD,OAAM;EACL,KAAK,GAAG,QAAQ,aAAa,CAAC;EAC9B,UAAU,OAAO,eAAe,WAAW;EAC3C,UAAU,OAAO,eAAe,WAAW;EAC3C"}