Added uuid command and function to format uuids

This commit is contained in:
2023-11-19 19:32:46 +01:00
parent 37f2678abb
commit 1b3e312365
3 changed files with 65 additions and 1 deletions

57
commands/uuid.js Normal file
View File

@@ -0,0 +1,57 @@
const { SlashCommandBuilder } = require('discord.js')
const { color } = require('../config/options.json')
const { getUUID, getIGN, getHeadURL, formatUuid } = require('../utils/utils.js')
module.exports = {
name: 'uuid',
description: 'Get a player\'s UUID',
type: 'slash',
dev: true,
data: new SlashCommandBuilder()
.setName('uuid')
.setDescription('Get a player\'s UUID')
.addStringOption(option => option
.setName('ign')
.setDescription('Player\'s name')
.setRequired(true)
),
/** @param { import('discord.js').ChatInputCommandInteraction } interaction */
async execute(interaction) {
await interaction.deferReply()
const ign = interaction.options.getString('ign')
const uuid = await getUUID(ign)
const formattedUuid = formatUuid(uuid)
const newIgn = await getIGN(uuid)
const head = await getHeadURL(ign)
const embedColor = Number(color.replace('#', '0x'))
if (!uuid) {
interaction.editReply({
description: 'That player doesn\'t exist!',
color: embedColor
})
return
}
await interaction.editReply({
embeds: [{
title: newIgn,
description: "**UUID:** `" + uuid + "`\n" +
"**Formatted UUID:** `" + formattedUuid + "`",
color: embedColor,
thumbnail: {
url: head
},
footer: {
text: interaction.guild.name + " | Developed by taken.lua",
icon_url: interaction.guild.iconURL({ dynamic: true })
}
}]
})
}
}

5
utils/functions/uuid.js Normal file
View File

@@ -0,0 +1,5 @@
function formatUuid(uuid) {
return uuid.replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/, '$1-$2-$3-$4-$5')
}
module.exports = { formatUuid }

View File

@@ -1,6 +1,7 @@
const { skywarsLevel } = require('./functions/skywars.js') const { skywarsLevel } = require('./functions/skywars.js')
const { bedwarsLevel } = require('./functions/bedwars.js') const { bedwarsLevel } = require('./functions/bedwars.js')
const { hypixelLevel } = require('./functions/hypixel.js') const { hypixelLevel } = require('./functions/hypixel.js')
const { formatUuid } = require('./functions/uuid.js')
const { guildLevel, scaledGEXP } = require('./functions/guild.js') const { guildLevel, scaledGEXP } = require('./functions/guild.js')
const { getUUID, getIGN, getPlayer, getGuild, getHeadURL } = require('./functions/account.js') const { getUUID, getIGN, getPlayer, getGuild, getHeadURL } = require('./functions/account.js')
@@ -14,5 +15,6 @@ module.exports = {
getIGN, getIGN,
getPlayer, getPlayer,
getGuild, getGuild,
getHeadURL getHeadURL,
formatUuid
} }