Question with creating a sticker

Why when creating a sticker using a image url as the attachment property it works. But this errors? My code is
const message = msg.channel.messages.cache.get('1194121140684202034'); // Message with attachment image
const atmt = message.attachments.find((att) => att.width != undefined && att.height != undefined && att.attachment != undefined);
msg.guild.stickers.create({ attachment: atmt.attachment, name: 'teststicker', tags: '\u{1F604}' });
const message = msg.channel.messages.cache.get('1194121140684202034'); // Message with attachment image
const atmt = message.attachments.find((att) => att.width != undefined && att.height != undefined && att.attachment != undefined);
msg.guild.stickers.create({ attachment: atmt.attachment, name: 'teststicker', tags: '\u{1F604}' });
which errors with
TypeError: Cannot read properties of undefined (reading 'pipe')
at Function.resolveFile (/opt/stratobotelite/node_modules/discord.js/src/structures/MessagePayload.js:251:85)
at GuildStickerManager.create (/opt/stratobotelite/node_modules/discord.js/src/managers/GuildStickerManager.js:61:47)
at eval (eval at eval (/opt/stratobotelite/src/bot/commands/Admin/eval.js:226:13), <anonymous>:3:20)
at module.exports.eval (/opt/stratobotelite/src/bot/commands/Admin/eval.js:226:13)
at module.exports.timedEval (/opt/stratobotelite/src/bot/commands/Admin/eval.js:196:60)
at module.exports.run (/opt/stratobotelite/src/bot/commands/Admin/eval.js:131:54)
at module.exports.runCommand (/opt/stratobotelite/src/bot/monitors/commandHandler.js:71:26)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async module.exports._run (/opt/stratobotelite/src/frameworks/klasa/lib/structures/Monitor.js:99:4)
TypeError: Cannot read properties of undefined (reading 'pipe')
at Function.resolveFile (/opt/stratobotelite/node_modules/discord.js/src/structures/MessagePayload.js:251:85)
at GuildStickerManager.create (/opt/stratobotelite/node_modules/discord.js/src/managers/GuildStickerManager.js:61:47)
at eval (eval at eval (/opt/stratobotelite/src/bot/commands/Admin/eval.js:226:13), <anonymous>:3:20)
at module.exports.eval (/opt/stratobotelite/src/bot/commands/Admin/eval.js:226:13)
at module.exports.timedEval (/opt/stratobotelite/src/bot/commands/Admin/eval.js:196:60)
at module.exports.run (/opt/stratobotelite/src/bot/commands/Admin/eval.js:131:54)
at module.exports.runCommand (/opt/stratobotelite/src/bot/monitors/commandHandler.js:71:26)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async module.exports._run (/opt/stratobotelite/src/frameworks/klasa/lib/structures/Monitor.js:99:4)
But adding a straight URL to the property works just fine. This code is literally just taking the attachment URL and putting it in for attachment property.
2 Replies
d.js toolkit
d.js toolkit11mo 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
⛧Bζ͜͡annerBomb⛧
nvm I'm so tired. I overlooked the property attachment which should be file
Want results from more Discord servers?
Add your server