Logging
This commit is contained in:
parent
db60021e08
commit
81c53cb304
|
@ -3,7 +3,6 @@ const { v4: uuidv4 } = require('uuid');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { EmbedBuilder } = require('discord.js');
|
const { EmbedBuilder } = require('discord.js');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const { exec } = require('child_process');
|
const { exec } = require('child_process');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -14,7 +13,11 @@ module.exports = {
|
||||||
const searchQuery = args.join(' ');
|
const searchQuery = args.join(' ');
|
||||||
const voiceChannel = message.member.voice.channel;
|
const voiceChannel = message.member.voice.channel;
|
||||||
|
|
||||||
|
console.log(`Received command: play ${searchQuery}`);
|
||||||
|
console.log(`Voice channel: ${voiceChannel ? voiceChannel.name : 'None'}`);
|
||||||
|
|
||||||
if (!voiceChannel) {
|
if (!voiceChannel) {
|
||||||
|
console.error('User is not in a voice channel.');
|
||||||
return message.reply('You need to be in a voice channel to play music!');
|
return message.reply('You need to be in a voice channel to play music!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,10 +49,12 @@ module.exports = {
|
||||||
|
|
||||||
message.channel.send({ embeds: [embed] });
|
message.channel.send({ embeds: [embed] });
|
||||||
|
|
||||||
|
console.log('Adding to queue and attempting to play.');
|
||||||
addToQueue(message.guild.id, tempFilePath, title, voiceChannel);
|
addToQueue(message.guild.id, tempFilePath, title, voiceChannel);
|
||||||
playNextInQueue(message.guild.id);
|
playNextInQueue(message.guild.id);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
console.error('Attachment is not an MP3 file.');
|
||||||
return message.reply('Only MP3 files are supported for uploads.');
|
return message.reply('Only MP3 files are supported for uploads.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,6 +83,7 @@ module.exports = {
|
||||||
|
|
||||||
message.channel.send({ embeds: [embed] });
|
message.channel.send({ embeds: [embed] });
|
||||||
|
|
||||||
|
console.log('Adding to queue and attempting to play.');
|
||||||
addToQueue(message.guild.id, tempFilePath, title, voiceChannel);
|
addToQueue(message.guild.id, tempFilePath, title, voiceChannel);
|
||||||
playNextInQueue(message.guild.id);
|
playNextInQueue(message.guild.id);
|
||||||
return;
|
return;
|
||||||
|
@ -104,12 +110,14 @@ module.exports = {
|
||||||
|
|
||||||
message.channel.send({ embeds: [embed] });
|
message.channel.send({ embeds: [embed] });
|
||||||
|
|
||||||
|
console.log('Adding to queue and attempting to play.');
|
||||||
addToQueue(message.guild.id, tempFilePath, title, voiceChannel);
|
addToQueue(message.guild.id, tempFilePath, title, voiceChannel);
|
||||||
playNextInQueue(message.guild.id);
|
playNextInQueue(message.guild.id);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
tempFilePath = path.join(__dirname, '../utils/tmp', `${uuidv4()}.mp3`);
|
tempFilePath = path.join(__dirname, '../utils/tmp', `${uuidv4()}.mp3`);
|
||||||
|
|
||||||
|
console.log(`YouTube link received: ${searchQuery}`);
|
||||||
exec(`yt-dlp --cookies ${path.join(__dirname, '../cookies.txt')} --print title ${searchQuery}`, (error, stdout, stderr) => {
|
exec(`yt-dlp --cookies ${path.join(__dirname, '../cookies.txt')} --print title ${searchQuery}`, (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error(`Error getting title: ${error}`);
|
console.error(`Error getting title: ${error}`);
|
||||||
|
@ -127,6 +135,8 @@ module.exports = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`Downloaded and saved: ${tempFilePath}`);
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor('#0099ff')
|
.setColor('#0099ff')
|
||||||
.setTitle('Now Playing')
|
.setTitle('Now Playing')
|
||||||
|
@ -136,12 +146,14 @@ module.exports = {
|
||||||
|
|
||||||
message.channel.send({ embeds: [embed] });
|
message.channel.send({ embeds: [embed] });
|
||||||
|
|
||||||
|
console.log('Adding to queue and attempting to play.');
|
||||||
addToQueue(message.guild.id, tempFilePath, title, voiceChannel);
|
addToQueue(message.guild.id, tempFilePath, title, voiceChannel);
|
||||||
playNextInQueue(message.guild.id);
|
playNextInQueue(message.guild.id);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
console.log(`Performing YouTube search: ${searchQuery}`);
|
||||||
exec(`yt-dlp --cookies ${path.join(__dirname, '../cookies.txt')} --dump-single-json "ytsearch:${searchQuery}"`, (error, stdout, stderr) => {
|
exec(`yt-dlp --cookies ${path.join(__dirname, '../cookies.txt')} --dump-single-json "ytsearch:${searchQuery}"`, (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error(`Error searching: ${error}`);
|
console.error(`Error searching: ${error}`);
|
||||||
|
@ -163,6 +175,8 @@ module.exports = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`Downloaded and saved: ${tempFilePath}`);
|
||||||
|
|
||||||
const embed = new EmbedBuilder()
|
const embed = new EmbedBuilder()
|
||||||
.setColor('#0099ff')
|
.setColor('#0099ff')
|
||||||
.setTitle('Now Playing')
|
.setTitle('Now Playing')
|
||||||
|
@ -172,6 +186,7 @@ module.exports = {
|
||||||
|
|
||||||
message.channel.send({ embeds: [embed] });
|
message.channel.send({ embeds: [embed] });
|
||||||
|
|
||||||
|
console.log('Adding to queue and attempting to play.');
|
||||||
addToQueue(message.guild.id, tempFilePath, title, voiceChannel);
|
addToQueue(message.guild.id, tempFilePath, title, voiceChannel);
|
||||||
playNextInQueue(message.guild.id);
|
playNextInQueue(message.guild.id);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue