chomens-bot-js/commands/list.js
2022-09-11 11:31:58 +07:00

38 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* eslint-disable max-len */
const sleep = (t) => new Promise((a) => setTimeout(a, t));
const {MessageEmbed} = require('discord.js');
module.exports = {
name: 'list',
alias: [],
description: 'List players',
usage: '',
trusted: 0,
execute: async function(bot) {
try {
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: 'Players:', color: 'green'}]));
await sleep(60);
for (const property of bot.tabcompleteplayers) {
if (property.match.startsWith('@')) continue;
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: `${property.match}`, color: 'yellow'}, {text: ' ', color: 'aqua'}, {text: `${bot.players.getPlayer(property.match).UUID}`, color: 'aqua'}]));
}
} catch (e) {
return;
}
},
discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc) {
try {
players = '';
for (const property of bot.tabcompleteplayers) {
if (property.match.startsWith('@')) continue;
players += `\`${property.match}\` \`${bot.players.getPlayer(property.match).UUID}\`` + '\n';
}
const Embed = new MessageEmbed()
.setColor('#FFFF00')
.setTitle('Players')
.setDescription(players);
channeldc.send({embeds: [Embed]});
} catch (e) {
return;
}
},
};