Sorry my code is dirty
and also I’m not a native english speaker
~
As the title goes, all spaces in msg.attachments.first().name are replaced by underbars and disappear if there is an underbar in the first
when a user sends a file with “$fur2mp3” in the chat window, the file must be converted through an external script,
but before that, there is a problem in the process of finding the name of the file
if the name of the file user sends does not contain underbar(‘_’) or space (‘ ‘), everything works fine, but if it does not, it fails to find the file (there are no errors or crashes btw)
This is a list of the file names and their values that I tried
_kirb space.fur –> kirb_space.fur
_kirb sp_ace.fur –> kirb_sp_ace.fur
kirb space.fur –> kirb_space.fur
commands.add('fur2mp3',() => {
fs.exists('buffer_furrendering.txt', function(exists){
if(exists){
msg.channel.send('Another file is being processed! Please wait!');
} else {
if(msg.attachments.first()){//checks if an attachment is sent
//arg = msg.attachments.first()
msg.channel.send('Uploading...');
download(msg.attachments.first().url, process.cwd());//Function
msg.channel.send('Uploaded!');
msg.channel.send(msg.attachments.first().name);
fs.exists(msg.attachments.first().name, function(exists){
if(exists){
msg.channel.send('Current Furnace Tracker Version : 0.6.5');
msg.channel.send('Converting...');
msg.channel.startTyping();
exec('fur2wav.bat' + ' ' + msg.attachments.first().name, (error, stdout, stderr) =>{
msg.channel.stopTyping();
fs.readFile('buffer_fur2wavmsg.txt', 'utf8', (err, gwav) => {
if (err) {
console.error(err);
return;
}
console.log(gwav);
msg.channel.send(gwav);
msg.channel.send({ files: ["furoutput.mp3"] });
});
});
console.log("exixts! : ",exists);
} else {
msg.channel.stopTyping();
msg.channel.send('The file does not exist!');
}});
} else { msg.channel.send('Send your file with this command!'); }
};
});
});
I tried this, ‘msg.attachments.first().name.join(‘ ‘)’ but uhh I think i was wrong
No error, but the bot returns these
Uploading…
Uploaded!
kirb_sp_ace.fur
The file does not exist!