47 lines
2.6 KiB
JavaScript
47 lines
2.6 KiB
JavaScript
const client = global.discord_client
|
|
const pool = global.db_pool;
|
|
const hubSettingsHandler = require('../messageHandlers/hub_settings.js');
|
|
|
|
if (!global.hubSettingsHandlers) global.hubSettingsHandlers = {};
|
|
|
|
const execute = async (interaction) => {
|
|
if (!interaction.guildId) return interaction.reply({ content: "This command can only be used in a server", ephemeral: true });
|
|
if (global.hubSettingsHandlers[interaction.user.id]) return interaction.reply({ content: "See DMs!", ephemeral: true });
|
|
try {
|
|
const guildId = interaction.guildId;
|
|
const hubResult = await pool.query(`SELECT * FROM hubs WHERE discordGuild = ?`, [guildId]);
|
|
if (hubResult.length === 0) {
|
|
delete global.hubSettingsHandlers[interaction.user.id];
|
|
return interaction.reply({ content: "This guild does not have a hub set up!", ephemeral: true });
|
|
}
|
|
// Proceed with settings menu
|
|
await interaction.reply({ ephemeral: true, content: "Getting things ready..." });
|
|
await interaction.user.send({ embeds: [{
|
|
title: `Hub Settings for ${hubResult[0].name}`,
|
|
description: `**Short Description:** ${hubResult[0].shortDescription}\n**Long Description:** ${hubResult[0].longDescription}\n**Allow Gift Purchase:** ${hubResult[0].allowGiftPurchase ? "Yes" : "No"}\n**Terms of Service:** ${hubResult[0].tos}\n\nHub Secret Key: ||${hubResult[0].secretKey}||`,
|
|
color: 0x00AE86,
|
|
fields: [
|
|
{ name: "Main Menu", value: "Type an option number, or `cancel` to close." },
|
|
{ name: "1. Edit Short Description", value: "Change the short description of the hub." },
|
|
{ name: "2. Edit Long Description", value: "Change the long description of the hub." },
|
|
{ name: "3. Toggle Allow Gift Purchase", value: "Enable or disable allowing users to buy gifts for others on this hub." },
|
|
{ name: "4. Edit Terms of Service", value: "Change the terms of service for this hub." },
|
|
{ name: "5. Regenerate Secret Key", value: "Generate a new secret key for this hub. (Old key will be invalidated)" },
|
|
{ name: "6. Parcel Auto-Import", value: "Set up automatic importing of Parcel purchases when linking." }
|
|
]
|
|
}] });
|
|
await interaction.user.send({ content: "Say an option number, or `cancel` to exit!" });
|
|
interaction.editReply({ephemeral: true, content: "Check your DMs!"});
|
|
global.hubSettingsHandlers[interaction.user.id] = {
|
|
step: 1,
|
|
hub: hubResult[0].id
|
|
};
|
|
global.dmHandlers[interaction.user.id] = hubSettingsHandler;
|
|
} catch (err) {
|
|
console.error(err);
|
|
delete global.productCreationData[interaction.user.id];
|
|
return interaction.editReply({ content: "An error occurred.", ephemeral: true });
|
|
}
|
|
};
|
|
|
|
module.exports = { execute }
|