Add BGM settings

This commit is contained in:
Christopher Cookman 2025-09-15 06:59:38 -06:00
parent 412884ffdd
commit eb53bd1056
2 changed files with 30 additions and 3 deletions

View file

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

View file

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