From ad734e0f6acf6c714683d303afcda9ea2fcf10a9 Mon Sep 17 00:00:00 2001 From: ChomeNS Date: Fri, 19 Aug 2022 11:19:55 +0700 Subject: [PATCH] try-catch *list --- commands/list.js | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/commands/list.js b/commands/list.js index fc479fa..dd0525f 100644 --- a/commands/list.js +++ b/commands/list.js @@ -8,23 +8,31 @@ module.exports = { usage: '', trusted: 0, execute: async function(bot) { - 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'}])); + 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) { - let players = ''; - for (const property of bot.tabcompleteplayers) { - if (property.match.startsWith('@')) continue; - players += `\`${property.match}\` › \`${bot.players.getPlayer(property.match).UUID}\`` + '\n'; + try { + let 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; } - const Embed = new MessageEmbed() - .setColor('#FFFF00') - .setTitle('Players') - .setDescription(players); - channeldc.send({embeds: [Embed]}); }, };