- Remove allowedSfxChannels from database schema and all code - Remove channel checking logic from all SFX commands (!sfx, /sfx, /soundboard) - Remove /config sfxchannels subcommand - Update config.json and example to remove channel restrictions - Simplify SFX system to work in any channel with bot access Benefits: - Better user experience - no confusing channel restrictions - Simpler configuration - fewer settings to manage - Cleaner codebase - reduced complexity - Universal access - SFX works anywhere the bot can send messages 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
const { SlashCommandBuilder, MessageFlags } = require('discord.js');
|
|
const sfxManager = require('../../services/sfxManager');
|
|
const voiceService = require('../../services/voiceService');
|
|
|
|
module.exports = {
|
|
data: new SlashCommandBuilder()
|
|
.setName('sfx')
|
|
.setDescription('Play a sound effect')
|
|
.addStringOption(option =>
|
|
option.setName('sound')
|
|
.setDescription('The sound effect to play')
|
|
.setRequired(true)
|
|
.setAutocomplete(true)
|
|
),
|
|
|
|
async execute(interaction, guildConfig) {
|
|
const sfxName = interaction.options.getString('sound');
|
|
|
|
// Check if user is in a voice channel
|
|
if (!interaction.member.voice.channel) {
|
|
return interaction.reply({
|
|
content: 'You need to be in a voice channel to use this command!',
|
|
flags: [MessageFlags.Ephemeral]
|
|
});
|
|
}
|
|
|
|
// Use the reusable SFX playing method
|
|
await sfxManager.playSFXInteraction(interaction, sfxName, guildConfig, 'slash');
|
|
},
|
|
|
|
async autocomplete(interaction, guildConfig) {
|
|
const focusedValue = interaction.options.getFocused().toLowerCase();
|
|
|
|
// Get all SFX names
|
|
const choices = sfxManager.getSFXNames();
|
|
|
|
// Filter based on what the user has typed
|
|
const filtered = choices
|
|
.filter(choice => choice.toLowerCase().includes(focusedValue))
|
|
.slice(0, 25); // Discord limits autocomplete to 25 choices
|
|
|
|
// Respond with the filtered choices
|
|
await interaction.respond(
|
|
filtered.map(choice => ({
|
|
name: choice,
|
|
value: choice
|
|
}))
|
|
);
|
|
}
|
|
}; |