Add hub command

This commit is contained in:
Christopher Cookman 2025-01-20 19:49:27 -07:00
parent 0e86e9a573
commit 4554d08b41
14 changed files with 21 additions and 12 deletions

View file

@ -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] = {

View file

@ -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 });

View file

@ -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]);

View file

@ -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 });

11
commands/hub.js Normal file
View file

@ -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 }

View file

@ -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 });

View file

@ -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 });

View file

@ -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 });

View file

@ -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 });

View file

@ -1,3 +1,2 @@
ALTER TABLE hubs
ADD COLUMN logChannel VARCHAR(255);
-- Uhh
ADD COLUMN hubUrl VARCHAR(255);

View file

@ -1,4 +0,0 @@
-- Insert a user
INSERT INTO users (robloxId, discordId, pairingCode, discordDisplayName)
VALUES (25226480, 289884287765839882, NULL, 'Chris C');

View file

@ -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');

View file

@ -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');