chomens-bot-js/commands/list.js

41 lines
1.3 KiB
JavaScript
Raw Normal View History

2022-08-14 05:51:45 -04:00
/* eslint-disable max-len */
2022-10-15 21:31:04 -04:00
const sleep = require('sleep-promise');
2022-08-14 05:51:45 -04:00
const {MessageEmbed} = require('discord.js');
module.exports = {
name: 'list',
alias: [],
description: 'List players',
usage: '',
trusted: 0,
execute: async function(bot) {
2022-08-19 00:19:55 -04:00
try {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: 'Players:', color: 'green'}]));
await sleep(60);
for (const property of bot.players.list) {
// if (property.match.startsWith('@')) continue;
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: `${property.name}`, color: 'yellow'}, {text: ' ', color: 'aqua'}, {text: `${property.UUID}`, color: 'aqua'}]));
2022-08-19 00:19:55 -04:00
}
} catch (e) {
return;
2022-08-14 05:51:45 -04:00
}
},
discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc) {
2022-08-19 00:19:55 -04:00
try {
2022-10-13 02:05:01 -04:00
let players = '';
for (const property of bot.players.list) {
// if (property.match.startsWith('@')) continue;
players += `\`${property.name}\` \`${property.UUID}\`` + '\n';
2022-08-19 00:19:55 -04:00
}
const Embed = new MessageEmbed()
.setColor('#FFFF00')
.setTitle('Players')
.setDescription(players);
channeldc.send({embeds: [Embed]});
2022-10-13 02:05:01 -04:00
players = '';
2022-08-19 00:19:55 -04:00
} catch (e) {
return;
2022-08-14 05:51:45 -04:00
}
},
};