Making !top amount show 2 messages with 20 people


#1

I’ve been able to navigate to the Lang/Commands-top10commands and I am trying to add another $.lang.register(‘top5.default’, ‘Top $1 $2: $3’); called $.lang.register(‘top5.default2’, ’ $1’); which would basically be all for the lang portion of adding the second message. In topCommand.js I am trying to add a second array list which would essentially push the remainder of the top list but Im a little unsure where the top list is coming from. Is it pulling a complete list and could I simply populate another array from the first or is it only pulling the amount set by amount points which can’t be over 15.

so far I have these modifications
starting at line 76 of topCommand:
if (command.equalsIgnoreCase(‘top’)) {
if (!$.bot.isModuleEnabled(’./systems/pointSystem.js’)) {
return;
}

        var temp = getTop5('points'),
            top = [],
			top2 = [],
			top3 = [],
            i;

        for (i in temp) {
            top.push((parseInt(i) + 1) + '. ' + $.resolveRank(temp[i].username) + ' ' + $.getPointsString(temp[i].value));
        }
		
		if(amountPoints > 15){
			top2 = top.splice(0,15);
			if (amountPoints<15){
				top3 = top.splice(15);
			}
		}
		
		if(top2[1]=null){
        $.say($.lang.get('top5.default', amountPoints, $.pointNameMultiple, top.join(', ')));
		}
		else{
			$.say($.lang.get('top5.default', amountPoints, $.pointNameMultiple, top2.join(', ')));
			$.say($.lang.get('top5.default2', top3.join(', ')));
			
			
		}
        return;

I am stuck at figuring out how to call upon 2 messages with one command to call upon these two lang lines in the lang/english/commands-top10Commands file

$.lang.register(‘top5.default’, ‘Top $1 $2: $3’);
$.lang.register(‘top5.default2’, ‘$1’);

I’ve also corrected the least and greatest values for the other lines. Any Ideas on how to work around sending both those lines?


#2

It does not pull a complete list. It pulls how many are configured in the bot to produce in the list. If you want more than 15 then modify the script:

        /*
         * @commandpath topamount - Set how many people who will show up in the !top points list
         */
        if (command.equalsIgnoreCase('topamount')) {
            if (action === undefined) {
                $.say($.whisperPrefix(sender) + $.lang.get('top5.amount.points.usage'));
                return;
            } else if (action > 15) { /* Here */
                $.say($.whisperPrefix(sender) + $.lang.get('top5.amount.max'));
                return;
            }

            amountPoints = action;
            $.inidb.set('settings', 'topListAmountPoints', amountPoints);
            $.say($.whisperPrefix(sender) + $.lang.get('top5.amount.points.set', amountPoints));
        }

        /*
         * @commandpath toptimeamount - Set how many people who will show up in the !toptime list
         */
        if (command.equalsIgnoreCase('toptimeamount')) {
            if (action === undefined) {
                $.say($.whisperPrefix(sender) + $.lang.get('top5.amount.time.usage'));
                return;
            } else if (action > 15) {  /* Here */
                $.say($.whisperPrefix(sender) + $.lang.get('top5.amount.max'));
                return;
            }

            amountTime = action;
            $.inidb.set('settings', 'topListAmountTime', amountTime);
            $.say($.whisperPrefix(sender) + $.lang.get('top5.amount.time.set', amountTime));
        }

#3

I mentioned above (though poorly worded) that I did modify that to 30 since two messages would allow AT LEAST 30 if not more since one message is 15 and that includes the top 20 announcement of $1 and $2 in lang/ top5.default while land top5.default2 only includes the list $3 which i renamed $1. So my question is how to return 2 message $.say lines in the one function? The function of Top is still only returning 1 line?


#4

So far I have

  1. corrected the minimum amount from 15 to 30 for an error message in set amount.
  2. I have added the proper lang/ top5.default2 to continue the list
  3. I have taken the array top[] and sliced it twice into top2[] top3[] , top2 at (0, 15) of top and top3 at (0) of top after the first 15 have been taken out.
  4. I’ve created the command for the two arrays to call upon default with the proper commands and top2[]
  5. I have an if statement so that if top2 and top3 never get generated due to it being less than 15 it simply sends the orignal say command.
  6. if top has been sliced into top2 and top3 then I want it to send the two messages I’ve set up

That is where I am stuck, I do no know why it does not send both commands? is it because the function is only returning one say command (the first one that shows?)


#5

So I got it working, the issue was the slice. I was slicing it wrong. Turns out I was splicing it and it wasn’t populating top3 array. I fixed it to slice it and It’s all good. I can post the code if you are interested in including it in the newest version? or edit it a little for your own uses and include it? I just need to work on top time amount now or create a new lang line for specifically topamount’s max at 30 and leave the rest at 15.

HERE IS THE TOP AMOUNT MODIFICATION
if (command.equalsIgnoreCase(‘topamount’)) {
if (action === undefined) {
$.say($.whisperPrefix(sender) + $.lang.get(‘top5.amount.points.usage’));
return;
} else if (action > 30) { /Modified to 30 from 15/
$.say($.whisperPrefix(sender) + $.lang.get(‘top5.amount.max’));
return;
}

        amountPoints = action;
        $.inidb.set('settings', 'topListAmountPoints', amountPoints);
        $.say($.whisperPrefix(sender) + $.lang.get('top5.amount.points.set', amountPoints));
    }

HERE IS THE TOP5 MODIFICATION
/**
* @commandpath top - Display the top people with the most points
*/
if (command.equalsIgnoreCase(‘top’)) {
if (!$.bot.isModuleEnabled(’./systems/pointSystem.js’)) {
return;
}

        var temp = getTop5('points'),
            top = [],
			top2 = [],
			top3 = [],
            i;

        for (i in temp) {
            top.push((parseInt(i) + 1) + '. ' + $.resolveRank(temp[i].username) + ' ' + $.getPointsString(temp[i].value));
        }
		
		if(amountPoints > 15){
			top2 = top.slice(0,15);
			top3 = top.slice(15);
			}
		
		if(amountPoints<=15){
        $.say($.lang.get('top5.default', amountPoints, $.pointNameMultiple, top.join(', ')));
		}
		else{
			$.say($.lang.get('top5.default', amountPoints, $.pointNameMultiple, top2.join(', ')));
			$.say($.lang.get('top5.default2', top3.join(', ')));
		}
        return;
    }

HERE IS THE LANG COMMANDS-TOP5COMMANDS MODIFICATIONS

$.lang.register(‘top5.default’, ‘Top $1 $2: $3’);
$.lang.register(‘top5.default2’, ‘$1’); /*added this line */
$.lang.register(‘top5.points-disabled’, ‘Points are disabled.’);
$.lang.register(‘top5.amount.points.usage’, ‘Usage: !topamount (amount) - Set how many viewers will appear in the !top points list.’);
$.lang.register(‘top5.amount.max’, ‘The max amount of users is 30.’); /*modfied this amount to 30 */
$.lang.register(‘top5.amount.points.set’, ‘$1 users will now show in the !top command.’);
$.lang.register(‘top5.amount.time.usage’, ‘Usage: !toptimeamount (amount) - Set how many viewers will appear in the !toptime list.’);
$.lang.register(‘top5.amount.time.set’, ‘$1 viwers will now show in the !toptime command.’);
$.lang.register(‘top5.reloadtopbots’, ‘Reloaded list of bots/users to ignore in top commands.’);


#6

I totally missed that part of the question :smiley:

Or you could have used $.paginateArray() to allow the bot to automatically split the data among multiple $.say() outputs. We use this in a few spots in the bot.

toptimeamount 40
[04-03-2018 @ 20:53:25.868 MDT] [CHAT] @IllusionaryBot, 40 viwers will now show in the !toptime command.
toptime
[04-03-2018 @ 20:53:27.094 MDT] [CHAT] @IllusionaryBot, Top Time: 1. ffmasterfoobar 43800 hours, 2. Pleeb illusionaryone 194 hours, 3. scaniatv 137 hours, 4. jojoboristhespide 64 hours, 5. sirjj777 17 hours, 6. kamehamedoukenn 14 hours, 7. castlevaniagirl 13 hours, 8. kuningasraiseri 10 hours, 9. moojack 9 hours, 10. mivixof 8 hours, 11. djabardo 6 hours, 12. jutley311 6 hours, 13. dweller_in_the_cellar 4 hours, 14. nightmisty1 4 hours, 15. ingamingfashion 3 hours, 16. bmxisaac123 3 hours, 17. mattmcgrath 3 hours
[04-03-2018 @ 20:53:27.110 MDT] [CHAT] @IllusionaryBot, Top Time: 18. intothetides 3 hours, 19. whiteysnakey 3 hours, 20. b9vqbr0u 2 hours, 21. licahqkl 2 hours, 22. j6m907xq 2 hours, 23. meje1ysj 2 hours, 24. tfeq05pk 2 hours, 25. sl0k2ojy 2 hours, 26. zxclmyjs 2 hours, 27. 7d1jz3ww 2 hours, 28. ucdec55y 2 hours, 29. qfxkwpya 2 hours, 30. 771znh63 2 hours, 31. foyskuet 2 hours, 32. 2gieybky 2 hours, 33. fgdgpcbn 2 hours, 34. amcqw4of 2 hours, 35. eh3jr2jq 2 hours, 36. fg0llqwh 2 hours, 37. vgkhgoa0 2 hours
[04-03-2018 @ 20:53:27.110 MDT] [CHAT] @IllusionaryBot, Top Time: 38. nxt2szxq 2 hours, 39. 40jmgiid 2 hours, 40. t5loasai 2 hours
        /*
         * @commandpath toptime - Display the top people with the most time
         */
        if (command.equalsIgnoreCase('toptime')) {
            var temp = getTop5('time'),
                top = [],
                i;

            for (i in temp) {
                top.push((parseInt(i) + 1) + '. ' + $.resolveRank(temp[i].username) + ' ' + $.getTimeString(temp[i].value, true));
            }
            $.paginateArray(top, 'toptime.list', ', ', true, sender);

            return;
        }

Language:

$.lang.register('toptime.list', 'Top Time: $1');

#7

I would probably also do:

Language:

$.lang.register('top5.amount.max', 'The max amount of users is $1.');

Script:

(function() {
    var bots = $.readFile('./addons/ignorebots.txt'),
        amountPoints = $.getSetIniDbNumber('settings', 'topListAmountPoints', 5),
        amountTime = $.getSetIniDbNumber('settings', 'topListAmountTime', 5),
        maxListSize = 40;
...
            } else if (action > maxListSize) {
                $.say($.whisperPrefix(sender) + $.lang.get('top5.amount.max', maxListSize));
                return;
            }

That way you could change it a bit on the fly, and only in one place (the maxListSize variable).

Cheers!