chomens-bot-js/commands/list.js
2022-11-16 18:41:30 +07:00

77 lines
2.2 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 {MessageEmbed} = require('discord.js');
module.exports = {
name: 'list',
alias: [],
description: 'List players',
usage: '',
trusted: 0,
execute: async function(bot) {
try {
const component = [];
component.push({text: 'Players ', color: 'green'});
component.push({text: '(', color: 'dark_gray'});
component.push({text: bot.players.list.length, color: 'gray'});
component.push({text: ')', color: 'dark_gray'});
component.push('\n');
for (const property of bot.players.list) {
// if (property.match.startsWith('@')) continue;
component.push({
text: property.name,
color: 'yellow',
clickEvent: {
action: 'copy_to_clipboard',
value: property.name,
},
hoverEvent: {
action: 'show_text',
contents: [{
text: 'Click here to copy the username to your clipboard',
color: 'green',
}],
},
});
component.push({
text: ' ',
color: 'dark_gray',
});
component.push({
text: property.UUID,
color: 'aqua',
clickEvent: {
action: 'copy_to_clipboard',
value: property.UUID,
},
hoverEvent: {
action: 'show_text',
contents: [{
text: 'Click here to copy the UUID to your clipboard',
color: 'green',
}],
},
});
component.push('\n');
}
component.pop();
bot.tellraw(selector, component);
} catch (e) {
return;
}
},
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {
try {
let players = '';
for (const property of bot.players.list) {
// if (property.match.startsWith('@')) continue;
players += `\`${property.name}\` \`${property.UUID}\`` + '\n';
}
const Embed = new MessageEmbed()
.setColor('#FFFF00')
.setTitle(`Players (${bot.players.list.length})`)
.setDescription(players.substring(0, 4096));
channeldc.send({embeds: [Embed]});
} catch (e) {
return;
}
},
};