[ ERROR: ]: source.on is not a function

let channelID = row.find(function (r) { return r.channeltype === 'welcome' }).channelid;
let channel = await bot.channels.cache.get(channelID)

const buffer = await canvas.toBuffer();
console.log('Buffer size:', buffer.length);

const attachment = new AttachmentBuilder(buffer, { name: 'welcome.png', description: 'welcome' });
console.log(buffer)
if (channel) {
try {
await channel.send({
content: `<@${guildMember.user.id}>`,
files: [attachment]
});
} catch (e) {
projectphil.logger({ string: e.message, type: 'error', location: __filename });
}
}
let channelID = row.find(function (r) { return r.channeltype === 'welcome' }).channelid;
let channel = await bot.channels.cache.get(channelID)

const buffer = await canvas.toBuffer();
console.log('Buffer size:', buffer.length);

const attachment = new AttachmentBuilder(buffer, { name: 'welcome.png', description: 'welcome' });
console.log(buffer)
if (channel) {
try {
await channel.send({
content: `<@${guildMember.user.id}>`,
files: [attachment]
});
} catch (e) {
projectphil.logger({ string: e.message, type: 'error', location: __filename });
}
}
`
58 Replies
d.js toolkit
d.js toolkit6mo 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!
treble/luna
treble/luna6mo ago
Show the full error
Night Ghost
Night GhostOP6mo ago
[ ERROR: ]: TypeError: source.on is not a function
at Function.create (C:\Users\mrpev\Desktop\[Project Phil]\PhilMultiBot\node_modules\delayed-stream\lib\delayed_stream.js:33:10)
at FormData.append (C:\Users\mrpev\Desktop\[Project Phil]\PhilMultiBot\node_modules\combined-stream\lib\combined_stream.js:45:37)
at FormData.append (C:\Users\mrpev\Desktop\[Project Phil]\PhilMultiBot\node_modules\form-data\lib\form_data.js:75:3)
at _REST.resolveRequest (C:\Users\mrpev\Desktop\[Project Phil]\PhilMultiBot\node_modules\@discordjs\rest\dist\index.js:1374:20)
at _REST.queueRequest (C:\Users\mrpev\Desktop\[Project Phil]\PhilMultiBot\node_modules\@discordjs\rest\dist\index.js:1312:46)
at _REST.request (C:\Users\mrpev\Desktop\[Project Phil]\PhilMultiBot\node_modules\@discordjs\rest\dist\index.js:1278:33)
at _REST.post (C:\Users\mrpev\Desktop\[Project Phil]\PhilMultiBot\node_modules\@discordjs\rest\dist\index.js:1252:17)
at TextChannel.send (C:\Users\mrpev\Desktop\[Project Phil]\PhilMultiBot\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:177:38)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Query.<anonymous> (C:\Users\mrpev\Desktop\[Project Phil]\PhilMultiBot\src\events\guildMemberAdd.js:213:29)
[ ERROR: ]: TypeError: source.on is not a function
at Function.create (C:\Users\mrpev\Desktop\[Project Phil]\PhilMultiBot\node_modules\delayed-stream\lib\delayed_stream.js:33:10)
at FormData.append (C:\Users\mrpev\Desktop\[Project Phil]\PhilMultiBot\node_modules\combined-stream\lib\combined_stream.js:45:37)
at FormData.append (C:\Users\mrpev\Desktop\[Project Phil]\PhilMultiBot\node_modules\form-data\lib\form_data.js:75:3)
at _REST.resolveRequest (C:\Users\mrpev\Desktop\[Project Phil]\PhilMultiBot\node_modules\@discordjs\rest\dist\index.js:1374:20)
at _REST.queueRequest (C:\Users\mrpev\Desktop\[Project Phil]\PhilMultiBot\node_modules\@discordjs\rest\dist\index.js:1312:46)
at _REST.request (C:\Users\mrpev\Desktop\[Project Phil]\PhilMultiBot\node_modules\@discordjs\rest\dist\index.js:1278:33)
at _REST.post (C:\Users\mrpev\Desktop\[Project Phil]\PhilMultiBot\node_modules\@discordjs\rest\dist\index.js:1252:17)
at TextChannel.send (C:\Users\mrpev\Desktop\[Project Phil]\PhilMultiBot\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:177:38)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Query.<anonymous> (C:\Users\mrpev\Desktop\[Project Phil]\PhilMultiBot\src\events\guildMemberAdd.js:213:29)
treble/luna
treble/luna6mo ago
what is line 21 of guildMemberAdd
Night Ghost
Night GhostOP6mo ago
No description
Night Ghost
Night GhostOP6mo ago
and it does return the buffer
Night Ghost
Night GhostOP6mo ago
No description
treble/luna
treble/luna6mo ago
Seems like an issue with your con.query then, #other-js-ts
Night Ghost
Night GhostOP6mo ago
you mean 213? not 21
treble/luna
treble/luna6mo ago
ah yeah 213
Night Ghost
Night GhostOP6mo ago
No description
Night Ghost
Night GhostOP6mo ago
that what the hole thing is
treble/luna
treble/luna6mo ago
i honestly have no clue, ive never seen this error before
Night Ghost
Night GhostOP6mo ago
ty for trying to help i wait to see if any else can help thanks so much
DD
DD6mo ago
hey, can you re-run your app with --enable-source-maps and get the error again
Night Ghost
Night GhostOP6mo ago
so like this node index.js -enable-source-maps?
vladdy
vladdy6mo ago
node --enable-source-maps index.js
DD
DD6mo ago
yes that ^
Night Ghost
Night GhostOP6mo ago
No description
Night Ghost
Night GhostOP6mo ago
thats what i get back
DD
DD6mo ago
yeah thanks, im trying to look into it
Night Ghost
Night GhostOP6mo ago
ty
vladdy
vladdy6mo ago
Whats your node version?
DD
DD6mo ago
what node version are you on
vladdy
vladdy6mo ago
🐌
Night Ghost
Night GhostOP6mo ago
No description
vladdy
vladdy6mo ago
Could you try upgrading node and seeing if that solves it?
Night Ghost
Night GhostOP6mo ago
to? try v20.15.01
DD
DD6mo ago
nevermind, we spoke about this and there is something terribly wrong happening here are you using npm?
Night Ghost
Night GhostOP6mo ago
yeah?
DD
DD6mo ago
can you run npm explain form-data
Night Ghost
Night GhostOP6mo ago
No description
DD
DD6mo ago
okay... npm ls @discordjs/rest
vladdy
vladdy6mo ago
Are you using form-data anywhere in your project?
Night Ghost
Night GhostOP6mo ago
No description
Night Ghost
Night GhostOP6mo ago
yeah
vladdy
vladdy6mo ago
and are you overriding the global formdata at all?
DD
DD6mo ago
how about this
vladdy
vladdy6mo ago
Imma delete that due to a possible api token leak
DD
DD6mo ago
are you doing something like, process.FormData = or globalThis.FormData = anywhere
Night Ghost
Night GhostOP6mo ago
nope
DD
DD6mo ago
this is a very strange problem!
Night Ghost
Night GhostOP6mo ago
i try remove that and see if it works
DD
DD6mo ago
what appears to be happening is that, instead of globalThis.FormData being the built-in node one, or, at worst the undici one that @discordjs/rest tries to use, your global FormData is the one from the module which shouldn't be happening unless you're doing that or one of your dependencies is doing that
vladdy
vladdy6mo ago
Well theres no dep using it
Night Ghost
Night GhostOP6mo ago
so i have removed it from the client file
DD
DD6mo ago
yea? and?
Night Ghost
Night GhostOP6mo ago
yip same thing
Night Ghost
Night GhostOP6mo ago
No description
Night Ghost
Night GhostOP6mo ago
"form-data": "^4.0.0",
"FormData": "^0.10.1",
"form-data": "^4.0.0",
"FormData": "^0.10.1",
imported now it works
vladdy
vladdy6mo ago
what is FormData
Night Ghost
Night GhostOP6mo ago
😤
vladdy
vladdy6mo ago
Neither of those are modules you need
Night Ghost
Night GhostOP6mo ago
No description
Night Ghost
Night GhostOP6mo ago
lol so how would i do my post thing with form data this nah that token not in use old one haha delete the require? TOS violating packages too? what packages oh yeah i not uppdate that package.json its been removed only one i see is ytdl-core discord player has youtube in it
Night Ghost
Night GhostOP6mo ago
but there spotify or SOUNDCLOUD
No description
Night Ghost
Night GhostOP6mo ago
bruh so no music bot so stupid
Want results from more Discord servers?
Add your server