Skip to content
This repository was archived by the owner on Jul 17, 2020. It is now read-only.

Commit 9b601e6

Browse files
committed
Removed pagination from listcommands - print one long message instead
1 parent 1a06e63 commit 9b601e6

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

source/commands.js

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -257,31 +257,19 @@ var partition = function ( list, maxSize ) {
257257

258258
return function ( args ) {
259259
var commands = Object.keys( bot.commands ),
260-
pagination = ' (page {0}/{1})',
261260
user_name = args.get( 'user_name' ),
262261
// 500 is the max, -2 for @ and space.
263-
maxSize = 498 - pagination.length - user_name.length,
262+
maxSize = 498 - user_name.length,
264263
//TODO: only call this when commands were learned/forgotten since last
265-
partitioned = partition( commands, maxSize ),
266-
267-
valid = /^(\d+|$)/.test( args.content ),
268-
page = Number( args.content ) || 0;
269-
270-
if(page > 0)
271-
page--;
272-
273-
if ( page >= partitioned.length || !valid ) {
274-
return args.codify( [
275-
'StackOverflow: Could not access page.',
276-
'IndexError: index out of range',
277-
'java.lang.IndexOutOfBoundsException',
278-
'IndexOutOfRangeException'
279-
].random() );
280-
}
281-
282-
var ret = partitioned[ page ].join( ', ' );
264+
partitioned = partition( commands, maxSize );
265+
266+
var lines = [];
267+
for (var i = 0; i < partitioned.length; i++) {
268+
lines.push(partitioned[i].join(', '));
269+
}
270+
var ret = lines.join('\n');
283271

284-
return ret + pagination.supplant( (page + 1), partitioned.length );
272+
return ret;
285273
};
286274
})();
287275

0 commit comments

Comments
 (0)