diff --git a/commands/createproduct.js b/commands/createproduct.js index 6fc8d4d..b130dcd 100644 --- a/commands/createproduct.js +++ b/commands/createproduct.js @@ -5,6 +5,7 @@ const createProdHandler = require('../messageHandlers/create_prod.js'); if (!global.productCreationData) global.productCreationData = {}; const execute = async (interaction) => { + if (!interaction.guildId) return interaction.reply({ content: "This command can only be used in a server", ephemeral: true }); console.log("Checking if user is already creating a product"); if (global.productCreationData[interaction.user.id]) return interaction.reply({ content: "You are already creating a product!", ephemeral: true }); global.productCreationData[interaction.user.id] = { diff --git a/commands/forcelink.js b/commands/forcelink.js index 8e4ee6f..3a2460d 100644 --- a/commands/forcelink.js +++ b/commands/forcelink.js @@ -2,6 +2,7 @@ const client = global.discord_client const pool = global.db_pool; const execute = async (interaction) => { + if (!interaction.guildId) return interaction.reply({ content: "This command can only be used in a server", ephemeral: true }); const robloxId = interaction.options.getNumber("roblox-id"); const discordID = interaction.options.getUser("discord-id"); if (!discordID?.id) return interaction.reply({ content: "You must provide a valid Discord User", ephemeral: true }); diff --git a/commands/forceunlink.js b/commands/forceunlink.js index 58ddf0c..f1e375a 100644 --- a/commands/forceunlink.js +++ b/commands/forceunlink.js @@ -2,6 +2,7 @@ const client = global.discord_client const pool = global.db_pool; const execute = async (interaction) => { + if (!interaction.guildId) return interaction.reply({ content: "This command can only be used in a server", ephemeral: true }); const robloxId = interaction.options.getNumber("roblox-id"); const discordID = interaction.options.getUser("discord-id")?.id; if (discordID) await pool.query("UPDATE users SET discordId = NULL WHERE discordId = ?", [discordID]); diff --git a/commands/give.js b/commands/give.js index 98b1397..bc6db9b 100644 --- a/commands/give.js +++ b/commands/give.js @@ -2,6 +2,7 @@ const client = global.discord_client const pool = global.db_pool; const execute = async (interaction) => { + if (!interaction.guildId) return interaction.reply({ content: "This command can only be used in a server", ephemeral: true }); var robloxID = interaction.options.getNumber("roblox-id") || null; const discordID = interaction.options.getUser("discord-id")?.id || null; if (!robloxID && !discordID) return interaction.reply({ content: "You must provide a Roblox ID or Discord ID", ephemeral: true }); @@ -18,6 +19,7 @@ const execute = async (interaction) => { // Get the hub for the guild const guildID = interaction.guild.id; + const [hub] = await pool.query('SELECT * FROM hubs WHERE discordGuild = ?', [guildID]); if (!hub) return interaction.reply({ content: "Hub not found for this guild", ephemeral: true }); diff --git a/commands/hub.js b/commands/hub.js new file mode 100644 index 0000000..bcf86fc --- /dev/null +++ b/commands/hub.js @@ -0,0 +1,11 @@ +const client = global.discord_client +const pool = global.db_pool; + +const execute = async (interaction) => { + if (!interaction.guildId) return interaction.reply({ content: "This command can only be used in a server", ephemeral: true }); + const [hub] = await pool.query('SELECT * FROM hubs WHERE discordGuild = ?', [interaction.guildId]); + if (hub.length === 0) return interaction.reply({ content: "This server is not a hub", ephemeral: true }); + interaction.reply({ content: `You can access the hub [here!](${hub.hubUrl})`}) +} + +module.exports = { execute } \ No newline at end of file diff --git a/commands/products.js b/commands/products.js index 0c16ab5..17f48e9 100644 --- a/commands/products.js +++ b/commands/products.js @@ -2,6 +2,7 @@ const client = global.discord_client const pool = global.db_pool; const execute = async (interaction) => { + if (!interaction.guildId) return interaction.reply({ content: "This command can only be used in a server", ephemeral: true }); try { const [hub] = await pool.query(`SELECT * FROM hubs WHERE discordGuild = ?`, [interaction.guildId]) if (!hub) return interaction.reply({ content: "This server doesn't have a hub", ephemeral: true }); diff --git a/commands/profile.js b/commands/profile.js index 52ecd8d..6940510 100644 --- a/commands/profile.js +++ b/commands/profile.js @@ -2,6 +2,7 @@ const client = global.discord_client const pool = global.db_pool; const execute = async (interaction) => { + if (!interaction.guildId) return interaction.reply({ content: "This command can only be used in a server", ephemeral: true }); var robloxID = interaction.options.getNumber("roblox-id") || null; const discordID = interaction.options.getUser("discord-id")?.id || null; if (!robloxID && !discordID) return interaction.reply({ content: "You must provide a Roblox ID or Discord ID", ephemeral: true }); diff --git a/commands/retrieve.js b/commands/retrieve.js index 3d7f551..ede9e89 100644 --- a/commands/retrieve.js +++ b/commands/retrieve.js @@ -3,6 +3,7 @@ const pool = global.db_pool; const crypto = require('crypto'); const execute = async (interaction) => { + if (!interaction.guildId) return interaction.reply({ content: "This command can only be used in a server", ephemeral: true }); // If discordID is provided, we need to find the robloxID const [user] = await pool.query('SELECT * FROM users WHERE discordId = ?', [interaction.user.id]); if (!user) return interaction.reply({ content: "User not found", ephemeral: true }); diff --git a/commands/revoke.js b/commands/revoke.js index d2c0a5a..9c07d72 100644 --- a/commands/revoke.js +++ b/commands/revoke.js @@ -2,6 +2,7 @@ const client = global.discord_client const pool = global.db_pool; const execute = async (interaction) => { + if (!interaction.guildId) return interaction.reply({ content: "This command can only be used in a server", ephemeral: true }); var robloxID = interaction.options.getNumber("roblox-id") || null; const discordID = interaction.options.getUser("discord-id")?.id || null; if (!robloxID && !discordID) return interaction.reply({ content: "You must provide a Roblox ID or Discord ID", ephemeral: true }); diff --git a/migrations/006_update_hubs_add_logChannel b/migrations/006_update_hubs_add_logChannel index 9b3f9c3..cacb242 100644 --- a/migrations/006_update_hubs_add_logChannel +++ b/migrations/006_update_hubs_add_logChannel @@ -1,3 +1,2 @@ ALTER TABLE hubs -ADD COLUMN logChannel VARCHAR(255); --- Uhh \ No newline at end of file +ADD COLUMN hubUrl VARCHAR(255); \ No newline at end of file diff --git a/migrations/007_update_hubs_add_hubUrl.sql b/migrations/007_update_hubs_add_hubUrl.sql new file mode 100644 index 0000000..e69de29 diff --git a/migrations/990_test_user.sql b/migrations/990_test_user.sql deleted file mode 100644 index 54eb6ab..0000000 --- a/migrations/990_test_user.sql +++ /dev/null @@ -1,4 +0,0 @@ --- Insert a user -INSERT INTO users (robloxId, discordId, pairingCode, discordDisplayName) -VALUES (25226480, 289884287765839882, NULL, 'Chris C'); - diff --git a/migrations/991_test_hub.sql b/migrations/991_test_hub.sql deleted file mode 100644 index f53df78..0000000 --- a/migrations/991_test_hub.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Insert a hub -INSERT INTO hubs (ownerId, discordGuild, name, shortDescription, longDescription, allowGiftPurchase, tos, bgmId, secretKey) -VALUES (289884287765839882, 1271619282853429330, 'Test Hub', 'A test hub', 'A test hub', TRUE, 'This Hub does not have any Terms of Service yet. If you are the Hub owner, you can update this under settings.', NULL, 'test_hub'); \ No newline at end of file diff --git a/migrations/992_test_prod.sql b/migrations/992_test_prod.sql deleted file mode 100644 index 3e9be84..0000000 --- a/migrations/992_test_prod.sql +++ /dev/null @@ -1,3 +0,0 @@ --- insert test product -INSERT INTO products (hubId, name, description, devProductID, decalId, stock, category) -VALUES ((SELECT id FROM hubs WHERE name = 'Test Hub'), 'Test Product', 'A test product', 1, NULL, -1, 'Test'); \ No newline at end of file