From eb53bd1056774d154ee20c3513c3596d7e849b34 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Mon, 15 Sep 2025 06:59:38 -0600 Subject: [PATCH] Add BGM settings --- commands/settings.js | 3 ++- messageHandlers/hub_settings.js | 30 ++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/commands/settings.js b/commands/settings.js index 943e1ab..290d6ff 100644 --- a/commands/settings.js +++ b/commands/settings.js @@ -42,7 +42,8 @@ const execute = async (interaction) => { { 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." }, - { name: "7. Delete hub and all products", value: "***__WARNING: THIS IS DANGEROUS__***" } + { name: "7. Set Background Music", value: "Set or change the background music for this hub." }, + { name: "99. Delete hub and all products", value: "***__WARNING: THIS IS DANGEROUS__***" } ] }] }); await interaction.user.send({ content: "Say an option number, or `cancel` to exit!" }); diff --git a/messageHandlers/hub_settings.js b/messageHandlers/hub_settings.js index 5ee4f54..f76cce1 100644 --- a/messageHandlers/hub_settings.js +++ b/messageHandlers/hub_settings.js @@ -72,7 +72,12 @@ const opts = { // Map of option number to step number } }, 7: { - step: 27, exec: async (hubId, uid) => { + step: 27, exec: (hubId, uid) => { + return 'Please provide a Roblox Audio Asset ID, or say `none` to disable. Say `cancel` to exit.'; + } + }, + 99: { + step: 99, exec: async (hubId, uid) => { // generate a random confirmation code const confirmationCode = crypto.randomBytes(8).toString('hex'); global.hubSettingsHandlers[uid].confirmationCode = confirmationCode; @@ -139,7 +144,28 @@ const execute = async (message) => { global.hubSettingsHandlers[message.author.id].step = 1; message.channel.send('Terms of Service updated.\n\nType an option number, or `cancel` to exit.'); break; - case 27: // Delete Hub + case 27: // Set Background Music + const bgmInput = message.content.trim(); + if (bgmInput.toLowerCase() === 'cancel') { + cancel(message.author); + return; + } + if (bgmInput.toLowerCase() === 'none') { + await pool.query('UPDATE hubs SET bgmId = NULL WHERE id = ?', [global.hubSettingsHandlers[message.author.id].hub]); + global.hubSettingsHandlers[message.author.id].step = 1; + message.channel.send('Background music disabled.\n\nType an option number, or `cancel` to exit.'); + return; + } + const audioId = parseInt(bgmInput); + if (isNaN(audioId) || audioId <= 0) { + message.channel.send('Invalid Audio Asset ID. Please provide a valid positive integer, or `none` to disable, or `cancel` to exit.'); + return; + } + await pool.query('UPDATE hubs SET bgmId = ? WHERE id = ?', [audioId, global.hubSettingsHandlers[message.author.id].hub]); + global.hubSettingsHandlers[message.author.id].step = 1; + message.channel.send('Background music updated.\n\nType an option number, or `cancel` to exit.'); + break; + case 99: // Delete Hub const confirmMatch = message.content.trim().match(/^confirm (\w{16})$/); if (message.content.toLowerCase() === 'cancel') { cancel(message.author);