UNPKG

2.1 kBJavaScriptView Raw
1exports.command = {
2 name: "wizlist", // Name of command to be executed (Max 10 chars)
3 autoload: true, // Should the command be autoloaded at startup
4 unloadable: true, // Can the command be unloaded dynamically
5 min_rank: 0, // Minimum rank to use to execute the command
6 display: "list of Wizzards",// Summary help text to show in the .help command (Max 60 chars)
7 help: "List of Wizzards.", // Full help text when .help <command> is used
8 usage: ".wizlist",
9
10 // Function to execute the command
11 execute: function(socket, command, command_access) {
12 var chalk = require('chalk');
13 var users = command_access.getUsersList();
14 var toShow = command_access.ranks.list.length;
15 if (toShow > 3) toShow = 3;
16 socket.write(chalk.green("+----------------------------------------------------------------------------+\r\n"));
17 var someone = false;
18 var online = "";
19 for (var level = command_access.ranks.list.length-1; level > command_access.ranks.list.length-1-toShow; level--) {
20 socket.write(chalk.yellow.bold(command_access.ranks.list[level]) + "\t: ");
21 online += chalk.blue.bold(command_access.ranks.list[level]) + "\t: ";
22 var counter = 0;
23 var ocounter = 0;
24 for (var u = 0; u < users.length; u++) {
25 if (users[u].rank === level) {
26 if (command_access.getOnlineUser(users[u].username)) {
27 someone = true;
28 ocounter++;
29 if (ocounter !== 0 && ocounter % 8 === 0)
30 online += "\n\t ";
31 online += users[u].username + "\t";
32 }
33 if (counter !== 0 && counter % 8 === 0)
34 socket.write("\n\t ");
35 socket.write(users[u].username + "\t");
36 counter++;
37 }
38 }
39 socket.write("\r\n");
40 online += "\r\n";
41 }
42 socket.write(chalk.green("+----------------------------------------------------------------------------+\r\n"));
43 if (someone) {
44 socket.write(chalk.bold("Of which, these are online:\r\n") + online);
45 } else {
46 socket.write(chalk.grey("None of them online at this moment.\r\n"));
47 }
48 socket.write(chalk.green("+----------------------------------------------------------------------------+\r\n"));
49 }
50}