From 4568fa05044cdc5ab6b0bc76d24d98c6155c8e08 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Mon, 20 Jan 2025 19:40:41 -0700 Subject: [PATCH] add display name to forcelink --- commands/forcelink.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/commands/forcelink.js b/commands/forcelink.js index cb2db8f..30eb1e3 100644 --- a/commands/forcelink.js +++ b/commands/forcelink.js @@ -3,21 +3,21 @@ const pool = global.db_pool; const execute = async (interaction) => { const robloxId = interaction.options.getNumber("roblox-id"); - const discordID = interaction.options.getUser("discord-id")?.id; - if (!discordID) return interaction.reply({ content: "You must provide a Discord User", ephemeral: true }); + const discordID = interaction.options.getUser("discord-id"); + if (!discordID?.id) return interaction.reply({ content: "You must provide a valid Discord User", ephemeral: true }); if (!robloxId) return interaction.reply({ content: "You must provide a Roblox ID", ephemeral: true }); try { - const [user] = await pool.query('SELECT * FROM users WHERE discordId = ?', [discordID]); + const [user] = await pool.query('SELECT * FROM users WHERE discordId = ?', [discordID.id]); if (user) return interaction.reply({ content: "This user is already linked to an account. Unlink before proceeding.", ephemeral: true }); const [row] = await pool.query('SELECT * FROM users WHERE robloxId = ?', [robloxId]); if (!row) { - await pool.query('INSERT INTO users (robloxId, discordId) VALUES (?, ?)', [robloxId, discordID]); + await pool.query('INSERT INTO users (robloxId, discordId, discordDisplayName) VALUES (?, ?, ?)', [robloxId, discordID.id, discordID.displayName]); return interaction.reply({ content: "Successfully linked accounts", ephemeral: true }); - } else if (row.discordId && row.discordId !== discordID) { + } else if (row.discordId && row.discordId !== discordID.id) { return interaction.reply({ content: "This Roblox ID is already linked to another account", ephemeral: true }); } else { - await pool.query('UPDATE users SET discordId = ? WHERE robloxId = ?', [discordID, robloxId]); + await pool.query('UPDATE users SET discordId = ? discordDisplayName = ? WHERE robloxId = ?', [discordID.id, discordID.displayName, robloxId]); } } catch (error) { log.error(error);