[ 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 toolkit7mo 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/luna7mo ago
Show the full error
Dangerous Nocturnal
[ 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/luna7mo ago
what is line 21 of guildMemberAdd
Dangerous Nocturnal
and it does return the buffer
treble/luna
treble/luna7mo ago
Seems like an issue with your con.query then, #other-js-ts
Dangerous Nocturnal
you mean 213? not 21
treble/luna
treble/luna7mo ago
ah yeah 213
Dangerous Nocturnal
that what the hole thing is
treble/luna
treble/luna7mo ago
i honestly have no clue, ive never seen this error before
Dangerous Nocturnal
ty for trying to help i wait to see if any else can help thanks so much
DD
DD7mo ago
hey, can you re-run your app with --enable-source-maps and get the error again
Dangerous Nocturnal
so like this node index.js -enable-source-maps?
vladdy
vladdy7mo ago
node --enable-source-maps index.js
DD
DD7mo ago
yes that ^
Dangerous Nocturnal
thats what i get back
DD
DD7mo ago
yeah thanks, im trying to look into it
Dangerous Nocturnal
ty
vladdy
vladdy7mo ago
Whats your node version?
DD
DD7mo ago
what node version are you on
vladdy
vladdy7mo ago
🐌
vladdy
vladdy7mo ago
Could you try upgrading node and seeing if that solves it?
Dangerous Nocturnal
to? try v20.15.01
DD
DD7mo ago
nevermind, we spoke about this and there is something terribly wrong happening here are you using npm?
Dangerous Nocturnal
yeah?
DD
DD7mo ago
can you run npm explain form-data
DD
DD7mo ago
okay... npm ls @discordjs/rest
vladdy
vladdy7mo ago
Are you using form-data anywhere in your project?
Dangerous Nocturnal
yeah
vladdy
vladdy7mo ago
and are you overriding the global formdata at all?
DD
DD7mo ago
how about this
vladdy
vladdy7mo ago
Imma delete that due to a possible api token leak
DD
DD7mo ago
are you doing something like, process.FormData = or globalThis.FormData = anywhere
Dangerous Nocturnal
nope
DD
DD7mo ago
this is a very strange problem!
Dangerous Nocturnal
i try remove that and see if it works
DD
DD7mo 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
vladdy7mo ago
Well theres no dep using it
Dangerous Nocturnal
so i have removed it from the client file
DD
DD7mo ago
yea? and?
Dangerous Nocturnal
yip same thing
Dangerous Nocturnal
"form-data": "^4.0.0",
"FormData": "^0.10.1",
"form-data": "^4.0.0",
"FormData": "^0.10.1",
imported now it works
vladdy
vladdy7mo ago
what is FormData
Dangerous Nocturnal
😤
vladdy
vladdy7mo ago
Neither of those are modules you need
Dangerous Nocturnal
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
Dangerous Nocturnal
but there spotify or SOUNDCLOUD
No description
Dangerous Nocturnal
bruh so no music bot so stupid

Did you find this page helpful?