@@ -23,6 +23,14 @@ describe('Command definitions (.json) are valid and follow Discord command schem
2323 }
2424 }
2525 }
26+ function checkDescription ( str , context ) {
27+ if ( typeof str !== 'string' ) {
28+ throw new Error ( `${ context } is not a string (type=${ typeof str } )` ) ;
29+ }
30+ if ( str . length > 100 ) {
31+ throw new Error ( `${ context } is too long (${ str . length } chars): "${ str } "` ) ;
32+ }
33+ }
2634 if ( files . length === 0 ) {
2735 test ( 'dummy test - no command definition files present' , ( ) => {
2836 expect ( true ) . toBe ( true ) ;
@@ -43,6 +51,9 @@ describe('Command definitions (.json) are valid and follow Discord command schem
4351 if ( parsed . type === 1 ) {
4452 test ( `${ file } (CHAT_INPUT) has valid description, name, and localizations` , ( ) => {
4553 expect ( typeof parsed . description ) . toBe ( 'string' ) ;
54+ if ( typeof parsed . description === 'string' && parsed . description . length > 100 ) {
55+ throw new Error ( `${ file } description is too long (${ parsed . description . length } chars): "${ parsed . description } "` ) ;
56+ }
4657 checkChatInput ( parsed . name , `${ file } name` ) ;
4758 expect ( parsed . name_localizations ) . toBeDefined ( ) ;
4859 for ( const key of localeKeys ) {
@@ -54,6 +65,7 @@ describe('Command definitions (.json) are valid and follow Discord command schem
5465 for ( const key of localeKeys ) {
5566 expect ( parsed . description_localizations [ key ] ) . toBeDefined ( ) ;
5667 expect ( typeof parsed . description_localizations [ key ] ) . toBe ( 'string' ) ;
68+ checkDescription ( parsed . description_localizations [ key ] , `${ file } description_localizations[${ key } ]` ) ;
5769 }
5870 } ) ;
5971 if ( parsed . options ) {
@@ -68,6 +80,7 @@ describe('Command definitions (.json) are valid and follow Discord command schem
6880 checkChatInput ( opt . name_localizations [ key ] , `${ file } option[${ i } ] name_localizations[${ key } ]` ) ;
6981 expect ( opt . description_localizations [ key ] ) . toBeDefined ( ) ;
7082 expect ( typeof opt . description_localizations [ key ] ) . toBe ( 'string' ) ;
83+ checkDescription ( opt . description_localizations [ key ] , `${ file } option[${ i } ] description_localizations[${ key } ]` ) ;
7184 }
7285 } ) ;
7386 }
0 commit comments