uuid fix discord + improve + change eslint a bit

This commit is contained in:
ChomeNS 2022-12-17 13:31:29 +07:00
parent 33701de582
commit 0712f78ce4
2 changed files with 13 additions and 13 deletions

View file

@ -10,7 +10,5 @@
"ecmaVersion": "latest", "ecmaVersion": "latest",
"sourceType": "module" "sourceType": "module"
}, },
"rules": { "rules": {}
"linebreak-style": 0
}
} }

View file

@ -3,13 +3,14 @@ module.exports = {
name: 'uuid', name: 'uuid',
alias: [], alias: [],
description: 'Gets the UUID of a player. If no player specified it will show your UUID instead', description: 'Gets the UUID of a player. If no player specified it will show your UUID instead',
usage: '', usage: '[player (required on Discord)]',
trusted: 0, trusted: 0,
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) { execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
if (args[0]) { if (args[0]) {
const playername = args.join(' ') const playername = args.join(' ')
const player = bot.playersAddedPlayers[playername] const player = bot.players.list.find((user) => user.name === playername)
if (player === undefined) throw new SyntaxError('Invalid Username') if (!player) throw new SyntaxError('Invalid username')
const playerUUID = player.UUID
bot.tellraw(selector, bot.tellraw(selector,
[ [
{ {
@ -17,11 +18,11 @@ module.exports = {
color: 'green' color: 'green'
}, },
{ {
text: player, text: playerUUID,
color: 'aqua', color: 'aqua',
clickEvent: { clickEvent: {
action: 'copy_to_clipboard', action: 'copy_to_clipboard',
value: player value: playerUUID
}, },
hoverEvent: { hoverEvent: {
action: 'show_text', action: 'show_text',
@ -61,21 +62,22 @@ module.exports = {
]) ])
} }
}, },
discordExecute (bot, username, sender, prefix, args, channeldc, message) { discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
if (args[0]) { if (args[0]) {
const playername = args.join(' ') const playername = args.join(' ')
const player = bot.playersAddedPlayers[playername] const player = bot.players.list.find((user) => user.name === playername)
if (player === undefined) throw new SyntaxError('Invalid UUID') if (!player) throw new SyntaxError('Invalid username')
const playerUUID = player.UUID
const Embed = new MessageEmbed() const Embed = new MessageEmbed()
.setColor(config.discord.embedsColors.normal) .setColor(config.discord.embedsColors.normal)
.setTitle('UUID') .setTitle('UUID')
.setDescription(`${playername}'s UUID: ${player}`) .setDescription(`${playername}'s UUID: ${playerUUID}`)
channeldc.send({ embeds: [Embed] }) channeldc.send({ embeds: [Embed] })
} else { } else {
const Embed = new MessageEmbed() const Embed = new MessageEmbed()
.setColor(config.discord.embedsColors.error) .setColor(config.discord.embedsColors.error)
.setTitle('Error') .setTitle('Error')
.setDescription('Invalid player name') .setDescription('No player name specified')
channeldc.send({ embeds: [Embed] }) channeldc.send({ embeds: [Embed] })
} }
} }