Attachments

do attachments not work? whenever i try one, it returns the error
node:events:491
throw er; // Unhandled 'error' event
^

TypeError: Cannot use 'in' operator to search for 'size' in ../pepperbot/src/logs/errors.log
at Attachment._patch (C:\Users\User\Desktop\VSCode projects\discordjs\pepperbot\node_modules\discord.js\src\structures\Attachment.js:34:16)
at new Attachment (C:\Users\User\Desktop\VSCode projects\discordjs\pepperbot\node_modules\discord.js\src\structures\Attachment.js:24:10)
at Object.execute (C:\Users\User\Desktop\VSCode projects\discordjs\pepperbot\src\commands\sendlog.js:20:24)
at Client.<anonymous> (C:\Users\User\Desktop\VSCode projects\discordjs\pepperbot\src\index.js:78:34)
at Client.emit (node:events:513:28)
at MessageCreateAction.handle (C:\Users\User\Desktop\VSCode projects\discordjs\pepperbot\node_modules\discord.js\src\client\actions\MessageCreate.js:28:14)
at module.exports [as MESSAGE_CREATE] (C:\Users\User\Desktop\VSCode projects\discordjs\pepperbot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\User\Desktop\VSCode projects\discordjs\pepperbot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (C:\Users\User\Desktop\VSCode projects\discordjs\pepperbot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:239:12)
at WebSocketManager.emit (C:\Users\User\Desktop\VSCode projects\discordjs\pepperbot\node_modules\@vladfrangu\async_event_emitter\dist\index.js:282:31)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)

Node.js v19.0.0
node:events:491
throw er; // Unhandled 'error' event
^

TypeError: Cannot use 'in' operator to search for 'size' in ../pepperbot/src/logs/errors.log
at Attachment._patch (C:\Users\User\Desktop\VSCode projects\discordjs\pepperbot\node_modules\discord.js\src\structures\Attachment.js:34:16)
at new Attachment (C:\Users\User\Desktop\VSCode projects\discordjs\pepperbot\node_modules\discord.js\src\structures\Attachment.js:24:10)
at Object.execute (C:\Users\User\Desktop\VSCode projects\discordjs\pepperbot\src\commands\sendlog.js:20:24)
at Client.<anonymous> (C:\Users\User\Desktop\VSCode projects\discordjs\pepperbot\src\index.js:78:34)
at Client.emit (node:events:513:28)
at MessageCreateAction.handle (C:\Users\User\Desktop\VSCode projects\discordjs\pepperbot\node_modules\discord.js\src\client\actions\MessageCreate.js:28:14)
at module.exports [as MESSAGE_CREATE] (C:\Users\User\Desktop\VSCode projects\discordjs\pepperbot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32)
at WebSocketManager.handlePacket (C:\Users\User\Desktop\VSCode projects\discordjs\pepperbot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (C:\Users\User\Desktop\VSCode projects\discordjs\pepperbot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:239:12)
at WebSocketManager.emit (C:\Users\User\Desktop\VSCode projects\discordjs\pepperbot\node_modules\@vladfrangu\async_event_emitter\dist\index.js:282:31)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)

Node.js v19.0.0
3 Replies
d.js toolkit
d.js toolkit15mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
ayeuhugyu
ayeuhugyuOP15mo ago
npm list discord.js [email protected] C:\Users\User\Desktop\VSCode projects\discordjs\pepperbot ├─┬ [email protected] │ └── [email protected] └── [email protected] node -v v19.0.0
const msgnoprefix = message.content.slice(
prefix.length + this.name.length + 1
);
if (!msgnoprefix.endsWith(".log")) {
msgnoprefix += ".log";
} // dw about this and above i've tested it it works

if (!`../pepperbot/src/logs/${msgnoprefix}`) return;

const path = `../pepperbot/src/logs/${msgnoprefix}`;
const attachment = new Attachment(path);

message.channel.send(attachment);
const msgnoprefix = message.content.slice(
prefix.length + this.name.length + 1
);
if (!msgnoprefix.endsWith(".log")) {
msgnoprefix += ".log";
} // dw about this and above i've tested it it works

if (!`../pepperbot/src/logs/${msgnoprefix}`) return;

const path = `../pepperbot/src/logs/${msgnoprefix}`;
const attachment = new Attachment(path);

message.channel.send(attachment);
and
and15mo ago
you can't just pass the attachment, you have to send it as a file like this:
message.channel.send({
files: [{
attachment: 'entire/path/to/file.log',
name: 'file.log'
}]
})
message.channel.send({
files: [{
attachment: 'entire/path/to/file.log',
name: 'file.log'
}]
})
Want results from more Discord servers?
Add your server