My bot is running on only Node.js v16 not v18

const express = require("express");
const app = express();

app.listen(() => console.log(`Bot Is Ready`));

app.use('/ping', (req, res) => {
res.send(new Date());
});

const Discord = require('discord.js');
const fs = require("fs");
const client = new Discord.Client({intents: 32767});
const { MessageAttachment } = require('discord.js');
const Canvas = require("canvas");
const { inviteTracker } = require("discord-inviter")

client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`)
})



client.on('guildMemberAdd', async (member, inviter, invite) => {
var x = member.guild.channels.cache.get("1020101321937911918")
const background = await Canvas.loadImage("wallpaper.png");
const canvas = Canvas.createCanvas(500, 357);
const ctx = canvas.getContext('2d');
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);



let text = member.displayName;
if(text.length > 13) {
text = text.slice(0, 13) + "...";
}

ctx.font = 'bold 30px sans-serif';
ctx.fillStyle = '#ffffff';
ctx.textAlign = "center"
ctx.fillText(text, 167, 300);
ctx.beginPath();
ctx.arc(165, 163, 105, 0, Math.PI * 2, false);
ctx.closePath();
ctx.clip();
const avatar = await Canvas.loadImage(member.user.displayAvatarURL({ format: 'png', size: 512 }));
ctx.drawImage(avatar, 60.00, 58.00, 210.99999999999997, 210.99999999999997);
const attachment = new Discord.MessageAttachment(canvas.toBuffer());
await x.send({files: [attachment]})
});
tracker = new inviteTracker(client)
tracker.on("guildMemberAdd", async (member, inviter, invite) => {
try {
let sleep = async (ms) => await new Promise(r => setTimeout(r,ms));
const ch = member.guild.channels.cache.get("1020101321937911918")
await sleep(500)
await ch.send({ content: `**Welcome To AsooL** <@${member.user.id}>` })
} catch (err) {
console.log(err)
}
})
client.login("token");
const express = require("express");
const app = express();

app.listen(() => console.log(`Bot Is Ready`));

app.use('/ping', (req, res) => {
res.send(new Date());
});

const Discord = require('discord.js');
const fs = require("fs");
const client = new Discord.Client({intents: 32767});
const { MessageAttachment } = require('discord.js');
const Canvas = require("canvas");
const { inviteTracker } = require("discord-inviter")

client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`)
})



client.on('guildMemberAdd', async (member, inviter, invite) => {
var x = member.guild.channels.cache.get("1020101321937911918")
const background = await Canvas.loadImage("wallpaper.png");
const canvas = Canvas.createCanvas(500, 357);
const ctx = canvas.getContext('2d');
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);



let text = member.displayName;
if(text.length > 13) {
text = text.slice(0, 13) + "...";
}

ctx.font = 'bold 30px sans-serif';
ctx.fillStyle = '#ffffff';
ctx.textAlign = "center"
ctx.fillText(text, 167, 300);
ctx.beginPath();
ctx.arc(165, 163, 105, 0, Math.PI * 2, false);
ctx.closePath();
ctx.clip();
const avatar = await Canvas.loadImage(member.user.displayAvatarURL({ format: 'png', size: 512 }));
ctx.drawImage(avatar, 60.00, 58.00, 210.99999999999997, 210.99999999999997);
const attachment = new Discord.MessageAttachment(canvas.toBuffer());
await x.send({files: [attachment]})
});
tracker = new inviteTracker(client)
tracker.on("guildMemberAdd", async (member, inviter, invite) => {
try {
let sleep = async (ms) => await new Promise(r => setTimeout(r,ms));
const ch = member.guild.channels.cache.get("1020101321937911918")
await sleep(500)
await ch.send({ content: `**Welcome To AsooL** <@${member.user.id}>` })
} catch (err) {
console.log(err)
}
})
client.login("token");
5 Replies
d.js toolkit
d.js toolkit17mo 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!
chewie
chewie17mo ago
Okay, and what exactly does this have to do with djs or any of our subpackages?
Sultan.
Sultan.OP17mo ago
how I can make it run in NodeJs v18 package.json :
{
"name": "nodejs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@types/node": "^18.0.6",
"canvas": "^2.11.2",
"discord-inviter": "^0.9.1",
"discord.js": "^13.10.3",
"express": "^4.18.1",
"node-fetch": "^3.2.6"
}
}
{
"name": "nodejs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@types/node": "^18.0.6",
"canvas": "^2.11.2",
"discord-inviter": "^0.9.1",
"discord.js": "^13.10.3",
"express": "^4.18.1",
"node-fetch": "^3.2.6"
}
}
d.js docs
d.js docs17mo ago
Please update Node.js to version 16.9.0 or newer! - Download - Linux (nodesource)
chewie
chewie17mo ago
further questions in #useful-servers or #other-js-ts as this has nothing to do with djs
Want results from more Discord servers?
Add your server