Bot seems to be uploading the same media file multiple times?

Bot has been perfectly fine for the past week. However, when simply posting a message as a bot that only contains a media file, the bot seems to be spam uploading it, again, and again.
14 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Nixxxxxx
NixxxxxxOP2y ago
`-- [email protected] node v16.14.0
console.log("yay downloaded and exists! UPLOAD");
try{
message.react("✅");
message.suppressEmbeds(true)
} catch (err) {
console.log(err)
};
console.log("file exists, sending message!");
message.channel.send({
files: [{
attachment: filepath
}]
})
.then(msg => {
console.log("end");
lmsg.delete();
})
.catch(console.error);
console.log("yay downloaded and exists! UPLOAD");
try{
message.react("✅");
message.suppressEmbeds(true)
} catch (err) {
console.log(err)
};
console.log("file exists, sending message!");
message.channel.send({
files: [{
attachment: filepath
}]
})
.then(msg => {
console.log("end");
lmsg.delete();
})
.catch(console.error);
For some reason, this is uploading again, and again, until I kill the bot. The media is uploading, probably the bot 'retrying' again?
Oscar
Oscar2y ago
What event are you responding to?
Nixxxxxx
NixxxxxxOP2y ago
when someone posts a instagram url, the bot would grab that url. The bot only logs the 'yay downloaded' and 'file exists' once, but it seems to upload the file over and over.
Oscar
Oscar2y ago
maybe when the bot sends the file, it triggers the event again?
Nixxxxxx
NixxxxxxOP2y ago
the bot never chats a url, and if it was to trigger the event again, the console log should show 'yay downloaded' and 'file exists' again.
Nixxxxxx
NixxxxxxOP2y ago
Oscar
Oscar2y ago
dunno sorry
Nixxxxxx
NixxxxxxOP2y ago
client.on('messageCreate', message => {
if (message.author.bot) return;
if (message.channel.type === 'DM') return;
client.on('messageCreate', message => {
if (message.author.bot) return;
if (message.channel.type === 'DM') return;
my only idea is discord.js thinks the file upload failed, and tries again... worked just fine till tonight, bot would only post once and be alright.
client.on('messageCreate', message => {
if (message.author.bot) return;
if (message.channel.type === 'DM') return;

let url = message.content.match(/https?:\/\/[^\s]+/);
if (url && url[0]) {
//console.log(message);
console.log("url0 exists!");
url=url[0]
if (url.includes("instagram.com")/* || url.includes("facebook.com/reel/")*/) {
const child_process = require('child_process');
var exe = 'gallery-dl.exe --cookies "'+url+'"';
if (url.includes("instagram.com")) {
exe = 'gallery-dl.exe --cookies ".\\www.instagram.com_cookies.txt" "'+url+'"'
};
if (url.includes("facebook.com/reel/")) {
exe = 'gallery-dl.exe --cookies ".\\www.facebook.com_cookies.txt" "'+url+'"'
};
const args = [];
console.log(args);
child_process.exec(exe, args, (err, stdout, stderr) => {
if (err) {
console.log(err);
try{
message.react("❌");
message.suppressEmbeds(true)
} catch (err) {
console.log(err)
};
} else {
var filepath = stdout.slice(2,-2);
console.log("---");
console.log("|-" + filepath + "-|");
console.log("---");
if(fs.existsSync(filepath)){
console.log("yay downloaded and exists! UPLOAD");
try{
message.react("✅");
message.suppressEmbeds(true)
} catch (err) {
console.log(err)
};
console.log("file exists, sending message!");
message.channel.send({
content: ':wave:',
files: [{
attachment: filepath
}]
})
.then(msg => {
console.log("end");
lmsg.delete();
})
.catch(console.error);
} else {
try{
message.react("⚠️");
message.suppressEmbeds(true)
} catch (err) {
console.log(err)
};
console.log("error");
}
}
});
}
}
});
client.on('messageCreate', message => {
if (message.author.bot) return;
if (message.channel.type === 'DM') return;

let url = message.content.match(/https?:\/\/[^\s]+/);
if (url && url[0]) {
//console.log(message);
console.log("url0 exists!");
url=url[0]
if (url.includes("instagram.com")/* || url.includes("facebook.com/reel/")*/) {
const child_process = require('child_process');
var exe = 'gallery-dl.exe --cookies "'+url+'"';
if (url.includes("instagram.com")) {
exe = 'gallery-dl.exe --cookies ".\\www.instagram.com_cookies.txt" "'+url+'"'
};
if (url.includes("facebook.com/reel/")) {
exe = 'gallery-dl.exe --cookies ".\\www.facebook.com_cookies.txt" "'+url+'"'
};
const args = [];
console.log(args);
child_process.exec(exe, args, (err, stdout, stderr) => {
if (err) {
console.log(err);
try{
message.react("❌");
message.suppressEmbeds(true)
} catch (err) {
console.log(err)
};
} else {
var filepath = stdout.slice(2,-2);
console.log("---");
console.log("|-" + filepath + "-|");
console.log("---");
if(fs.existsSync(filepath)){
console.log("yay downloaded and exists! UPLOAD");
try{
message.react("✅");
message.suppressEmbeds(true)
} catch (err) {
console.log(err)
};
console.log("file exists, sending message!");
message.channel.send({
content: ':wave:',
files: [{
attachment: filepath
}]
})
.then(msg => {
console.log("end");
lmsg.delete();
})
.catch(console.error);
} else {
try{
message.react("⚠️");
message.suppressEmbeds(true)
} catch (err) {
console.log(err)
};
console.log("error");
}
}
});
}
}
});
Nixxxxxx
NixxxxxxOP2y ago
Nixxxxxx
NixxxxxxOP2y ago
Nixxxxxx
NixxxxxxOP2y ago
it never prints 'end' anymore.
Nixxxxxx
NixxxxxxOP2y ago
Instagram
Nixxxxxx
NixxxxxxOP8mo ago
RequestAbortedError [AbortError]: Request aborted
at RequestHandler.abort (C:\Users\nicen\Downloads\InstagramBot2\node_modules\undici\lib\client.js:1391:44)
at abort (C:\Users\nicen\Downloads\InstagramBot2\node_modules\undici\lib\api\abort-signal.js:8:10)
at AbortSignal.self.<computed> (C:\Users\nicen\Downloads\InstagramBot2\node_modules\undici\lib\api\abort-signal.js:29:5)
at AbortSignal.[nodejs.internal.kHybridDispatch] (node:internal/event_target:647:20)
at AbortSignal.dispatchEvent (node:internal/event_target:589:26)
at abortSignal (node:internal/abort_controller:283:10)
at AbortController.abort (node:internal/abort_controller:314:5)
at Timeout.<anonymous> (C:\Users\nicen\Downloads\InstagramBot2\node_modules\@discordjs\rest\dist\index.js:589:71)
at listOnTimeout (node:internal/timers:559:17)
at processTimers (node:internal/timers:502:7) {
code: 'UND_ERR_ABORTED'
}
RequestAbortedError [AbortError]: Request aborted
at RequestHandler.abort (C:\Users\nicen\Downloads\InstagramBot2\node_modules\undici\lib\client.js:1391:44)
at abort (C:\Users\nicen\Downloads\InstagramBot2\node_modules\undici\lib\api\abort-signal.js:8:10)
at AbortSignal.self.<computed> (C:\Users\nicen\Downloads\InstagramBot2\node_modules\undici\lib\api\abort-signal.js:29:5)
at AbortSignal.[nodejs.internal.kHybridDispatch] (node:internal/event_target:647:20)
at AbortSignal.dispatchEvent (node:internal/event_target:589:26)
at abortSignal (node:internal/abort_controller:283:10)
at AbortController.abort (node:internal/abort_controller:314:5)
at Timeout.<anonymous> (C:\Users\nicen\Downloads\InstagramBot2\node_modules\@discordjs\rest\dist\index.js:589:71)
at listOnTimeout (node:internal/timers:559:17)
at processTimers (node:internal/timers:502:7) {
code: 'UND_ERR_ABORTED'
}
Any tags I can apply to the send message request to only try once? Is there any other options to adjust in the future regards to this? Would be nice if there could be a way to just only set retries count on the uploading message part.
Want results from more Discord servers?
Add your server