import { Client, CommandInteraction } from 'discord.js'; import { getPlayerUUID } from "../utils/mojangUsernameAPI.js"; import express from 'express'; import mysql from 'mysql'; const dbConfig = { host: 'mysql.apexhosting.gdn', user: 'apexMC1783493', password: 'MJOhHMjyZyhW1yKdpWbM6oyr', database: 'apexMC1783493', port: 3306 }; const pool = mysql.createPool(dbConfig); export default { name: "verify", description: "Verifies the user.", options: [ { name: "username", description: "The username to verify.", type: "STRING", required: true } ], // Add command options if needed permissions: ["Administrator"], // Add required permissions if needed async function({ interaction }) { try { const username = interaction.options.getString('username'); await interaction.reply({ content: "Trying to verify..." }); const uuid = await getPlayerUUID(username); console.log("Player UUID:", uuid); await pool.query('INSERT INTO players (username, uuid) VALUES (?, ?)', [username, uuid], (error) => { if (error) { interaction.reply({ content: "Something went wrong.." }); } else { interaction.reply({ content: "Successfully verified " + username}); } }); // If you want to send another message after fetching the UUID await interaction.followUp({ content: "Verification successful!" }); } catch (error) { console.error("Error:", error); await interaction.followUp({ content: "An error occurred while verifying." }); } } };