#welcome canvas v14.5
12 messages · Page 1 of 1 (latest)
- 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 staff
const Canvas = require('canvas')
const { createCanvas, loadImage } = require('canvas');
client.on('guildMemberAdd', async (member) => {
const welcomeChannel = client.channels.cache.get('1188962541842485353');
const rulesChannel = client.channels.cache.get('1192109584777760868');
const verifyChannel = client.channels.cache.get('1193611427450200078');
const infoChannel = client.channels.cache.get('1192102711718596688');
if (welcomeChannel && rulesChannel && verifyChannel && infoChannel) {
const canvas = createCanvas(1024, 500);
const ctx = canvas.getContext('2d');
const background = await loadImage("C:/Users/Utente/Downloads/static.png");
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);
ctx.font = '72px sans-serif';
ctx.fillStyle = '#ffffff';
ctx.fillText('Welcome', 360, 360);
ctx.beginPath();
ctx.arc(512, 166, 128, 0, Math.PI * 2, true);
ctx.stroke();
ctx.fill();
ctx.font = '42px sans-serif';
ctx.textAlign = 'center';
ctx.fillText(member.user.tag.toUpperCase(), 512, 410);
ctx.font = '32px sans-serif';
ctx.fillText(`You are the ${member.guild.memberCount}th`, 512, 455);
ctx.beginPath();
ctx.arc(512, 166, 119, 0, Math.PI * 2, true);
ctx.closePath();
ctx.clip();
const avatar = await loadImage(member.user.displayAvatarURL({ format: 'png', size: 1024 }));
ctx.drawImage(avatar, 393, 47, 238, 238);
const attachment = new MessageAttachment(canvas.toBuffer(), `welcome-${member.id}.png`);
try {
welcomeChannel.send(`:wave: Hello ${member}, welcome to ${member.guild.name}!`, { files: [attachment] });
welcomeChannel.send(`Don't forget to read the rules in ${rulesChannel} and verify yourself in ${verifyChannel}. For more information, check out ${infoChannel}.`);
} catch (error) {
console.error("Errore nell invio del messaggio di benvenuto", error);
}
}
});
welcome canvas v14.5
you need the Guilds and GuildMembers intents
const Discord = require("discord.js")
const client = new Discord.Client({ intents: Object.values(Discord.IntentsBitField.Flags)})
Tag suggestion for @tall vapor:
We highly recommend only specifying the intents you actually need.
- Note, that
98303,32767or whatever other magic number you read that represents "all intents", gets outdated as soon as new intents are introduced. - The number will always represent the same set of intents, and will not include new ones. There is no magic "all intents" bit.
Are you on v14 or v13? Because MessageAttachment is v13 but IntentsBitField is v14
V14.5
Then you should:
- update your code to use EmbedBuilder
- update to 14.14.1
- only pass the intents you use, not what you currently do
done but nothing changes, always the same
How can you say you did those things and then post the exact same unchanged code in a new post today