mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 06:28:53 +00:00
fix: Add more logging to /play command
This commit is contained in:
1 parent
931ae61ff8
commit
389e60baad
1 file changed
+18
-2
@@ -33,6 +33,8 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!searchResult || searchResult.tracks.length === 0) {
|
if (!searchResult || searchResult.tracks.length === 0) {
|
||||||
|
logger.debug(`No results found for query: ${query}`);
|
||||||
|
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
@@ -49,6 +51,8 @@ module.exports = {
|
|||||||
searchResult.tracks[0].raw.duration === 0 &&
|
searchResult.tracks[0].raw.duration === 0 &&
|
||||||
searchResult.tracks[0].source === 'youtube'
|
searchResult.tracks[0].source === 'youtube'
|
||||||
) {
|
) {
|
||||||
|
logger.debug(`Unsupported audio source. Query: ${query}. Track is live, 0 duration and from YouTube.`);
|
||||||
|
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
@@ -83,6 +87,8 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
logger.debug(`player.play() successful. Query: ${query}.`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.message.includes('Sign in to confirm your age')) {
|
if (error.message.includes('Sign in to confirm your age')) {
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
@@ -102,6 +108,8 @@ module.exports = {
|
|||||||
error.message.includes('Failed to fetch resources for ytdl streaming'))) ||
|
error.message.includes('Failed to fetch resources for ytdl streaming'))) ||
|
||||||
error.message.includes('Could not extract stream for this track')
|
error.message.includes('Could not extract stream for this track')
|
||||||
) {
|
) {
|
||||||
|
logger.debug(error, `Found track but failed to retrieve audio. Query: ${query}.`);
|
||||||
|
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
@@ -114,6 +122,8 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (error.message === 'Cancelled') {
|
if (error.message === 'Cancelled') {
|
||||||
|
logger.debug(error, `Operation cancelled. Query: ${query}.`);
|
||||||
|
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
@@ -125,13 +135,14 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.error('Failed to play track with player.play()');
|
logger.error(error, 'Failed to play track with player.play(), unhandled error.');
|
||||||
logger.error(error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let queue = useQueue(interaction.guild.id);
|
let queue = useQueue(interaction.guild.id);
|
||||||
|
|
||||||
if (!queue) {
|
if (!queue) {
|
||||||
|
logger.warn(`After player.play(), queue is undefined. Query: ${query}.`);
|
||||||
|
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
@@ -151,6 +162,8 @@ module.exports = {
|
|||||||
let durationFormat = track.raw.duration === 0 || track.duration === '0:00' ? '' : `\`${track.duration}\``;
|
let durationFormat = track.raw.duration === 0 || track.duration === '0:00' ? '' : `\`${track.duration}\``;
|
||||||
|
|
||||||
if (searchResult.playlist && searchResult.tracks.length > 1) {
|
if (searchResult.playlist && searchResult.tracks.length > 1) {
|
||||||
|
logger.debug(`Playlist found and added with player.play(). Query: ${query}.`);
|
||||||
|
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
@@ -172,6 +185,8 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (queue.currentTrack === track && queue.tracks.data.length === 0) {
|
if (queue.currentTrack === track && queue.tracks.data.length === 0) {
|
||||||
|
logger.debug(`Track found and added with player.play(), started playing. Query: ${query}.`);
|
||||||
|
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
@@ -189,6 +204,7 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.debug(`Track found and added with player.play(), added to queue. Query: ${query}.`);
|
||||||
return await interaction.editReply({
|
return await interaction.editReply({
|
||||||
embeds: [
|
embeds: [
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
|
|||||||
Reference in new issue
Block a user