From f252dab0b73c01e3de808a81883b1387282236b6 Mon Sep 17 00:00:00 2001 From: ChomeNS Date: Thu, 10 Nov 2022 20:03:14 +0700 Subject: [PATCH] show vanished + list improve + UUID not uuid --- commands/botuser.js | 2 +- commands/list.js | 49 ++++++++++++++++++++++++++++++++++++++++----- plugins/players.js | 22 +++++++++++--------- 3 files changed, 58 insertions(+), 15 deletions(-) diff --git a/commands/botuser.js b/commands/botuser.js index e14cf3f..a949de7 100644 --- a/commands/botuser.js +++ b/commands/botuser.js @@ -7,7 +7,7 @@ module.exports = { usage: '', trusted: 0, execute: function(bot) { - bot.tellraw('@a', [{text: 'The bot\'s username is: ', color: 'white'}, {text: `${bot.username}`, color: 'gold', clickEvent: {action: 'copy_to_clipboard', value: `${bot.username}`}, hoverEvent: {action: 'show_text', contents: [{text: 'Click here to copy the username to your clipboard', color: 'green'}]}}, {text: ' and the UUID is: '}, {text: `${bot.uuid}`, color: 'aqua', clickEvent: {action: 'copy_to_clipboard', value: `${bot.uuid}`}, hoverEvent: {action: 'show_text', contents: [{text: 'Click here to copy the uuid to your clipboard', color: 'green'}]}}]); + bot.tellraw('@a', [{text: 'The bot\'s username is: ', color: 'white'}, {text: `${bot.username}`, color: 'gold', clickEvent: {action: 'copy_to_clipboard', value: `${bot.username}`}, hoverEvent: {action: 'show_text', contents: [{text: 'Click here to copy the username to your clipboard', color: 'green'}]}}, {text: ' and the UUID is: '}, {text: `${bot.uuid}`, color: 'aqua', clickEvent: {action: 'copy_to_clipboard', value: `${bot.uuid}`}, hoverEvent: {action: 'show_text', contents: [{text: 'Click here to copy the UUID to your clipboard', color: 'green'}]}}]); }, discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { const Embed = new MessageEmbed() diff --git a/commands/list.js b/commands/list.js index 7b1957a..09a7b15 100644 --- a/commands/list.js +++ b/commands/list.js @@ -1,5 +1,4 @@ /* eslint-disable max-len */ -const sleep = require('sleep-promise'); const {MessageEmbed} = require('discord.js'); module.exports = { name: 'list', @@ -9,12 +8,52 @@ module.exports = { trusted: 0, execute: async function(bot) { try { - bot.tellraw('@a', [{text: 'Players:', color: 'green'}]); - await sleep(60); + 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; - bot.tellraw('@a', [{text: `${property.name}`, color: 'yellow'}, {text: ' › ', color: 'aqua'}, {text: `${property.UUID}`, color: 'aqua'}]); + 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('@a', component); } catch (e) { return; } @@ -28,7 +67,7 @@ module.exports = { } const Embed = new MessageEmbed() .setColor('#FFFF00') - .setTitle('Players') + .setTitle(`Players (${bot.players.list.length})`) .setDescription(players.substring(0, 4096)); channeldc.send({embeds: [Embed]}); } catch (e) { diff --git a/plugins/players.js b/plugins/players.js index 6f7ac6a..197f687 100644 --- a/plugins/players.js +++ b/plugins/players.js @@ -80,7 +80,7 @@ class TabCompletePlayerRequester { } } -function inject(bot) { +function inject(bot, dcclient, config) { bot.players = new PlayerList(); bot.requester = new TabCompletePlayerRequester(bot); @@ -107,8 +107,10 @@ function inject(bot) { }); function addPlayer(player, packet) { - // if (bot.players.getPlayer(player)) bot.emit('player_unvanished', player, packet); - /* else */bot.emit('player_added', player, packet); + if (bot.options.host !== 'sus.shhnowisnottheti.me') { + if (bot.players.getPlayer(player)) bot.emit('player_unvanished', player, packet); + else bot.emit('player_added', player, packet); + } bot.players.addPlayer(player); } @@ -144,15 +146,17 @@ function inject(bot) { } async function removePlayer(player, packet) { - /* const fullPlayer = bot.players.getPlayer(player); + if (bot.options.host !== 'sus.shhnowisnottheti.me') { + const fullPlayer = bot.players.getPlayer(player); - const players = await bot.requester.getPlayerList(); + const players = await bot.requester.getPlayerList(); - if (fullPlayer && players.some((name) => name === fullPlayer.name)) { - bot.emit('player_vanished', player); + if (fullPlayer && players.some((name) => name === fullPlayer.name)) { + bot.emit('player_vanished', player); - return; - } */ + return; + } + } bot.emit('player_removed', player, packet);