Skip to content

Commit

Permalink
fix: error handling for missing audio files
Browse files Browse the repository at this point in the history
  • Loading branch information
me-AC committed Aug 6, 2024
1 parent dd1a12b commit e41cee7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Binary file added audio/😮Aahh.mp3
Binary file not shown.
12 changes: 7 additions & 5 deletions bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ client.on('messageCreate', async (message) => {
rows.push(new ActionRowBuilder().addComponents(buttons.slice(i, i + 5)));
}

//Stop Button
//Stop Button at the end
rows.push(
new ActionRowBuilder().addComponents(
new ButtonBuilder()
Expand All @@ -113,8 +113,6 @@ client.on('messageCreate', async (message) => {
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isButton()) return;

// if (interaction.customId === 'Stop') return;

// Extract the audio file index from the button ID
const fileIndex = parseInt(interaction.customId.split('_')[1]);

Expand All @@ -126,8 +124,12 @@ client.on(Events.InteractionCreate, async (interaction) => {
// Get the selected audio file
const selectedFile = audioFiles[fileIndex];

if (!selectedFile) return;

if (!selectedFile) {
interaction.reply({
content: 'No audio file found!',
});
return;
}
// Get the member's voice channel
const voiceChannel = interaction.member.voice.channel;

Expand Down

0 comments on commit e41cee7

Please sign in to comment.