Add reply message if no results found

This commit is contained in:
Marius Begby committed 2023-07-07 18:51:31 +02:00
1 parent a74b895ed9
commit 662223d2a9
1 file changed
+17 -1
+17 -1
View File
@@ -30,6 +30,20 @@ module.exports = {
const queue = useQueue(interaction.guild.id);
const query = interaction.options.getString('query');
const results = await player.search(query);
if (!results || results.tracks.length === 0) {
return await interaction.editReply({
embeds: [
new EmbedBuilder()
.setDescription(
`**No track found**\nNo results found for \`${query}\`.`
)
.setColor(embedColors.colorWarning)
]
});
}
try {
const { track } = await player.play(
interaction.member.voice.channel,
@@ -61,7 +75,9 @@ module.exports = {
]
});
} catch (e) {
console.log(`Error occured while trying to play track:\n\n${e}`);
console.log(
`Error: Error occured while trying to play track:\n\n${e}`
);
throw e;
}
}