UnNainTrue
UnNainTrue
DIAdiscord.js - Imagine an app
Created by UnNainTrue on 4/5/2024 in #djs-questions
The image is not sent
Oui oui j'en parlerais a mon cheval
27 replies
DIAdiscord.js - Imagine an app
Created by UnNainTrue on 4/5/2024 in #djs-questions
The image is not sent
Bah nique ca mère je vais me débrouiller puisque personne ne veux m'aider ici
27 replies
DIAdiscord.js - Imagine an app
Created by UnNainTrue on 4/5/2024 in #djs-questions
The image is not sent
There's really something I don't understand, but in my code it doesn't work.
27 replies
DIAdiscord.js - Imagine an app
Created by UnNainTrue on 4/5/2024 in #djs-questions
The image is not sent
The guide is for people who want to create an order. I haven't figured out how to attach a canvas-generated file to my code. I'm sorry if I sound silly.
27 replies
DIAdiscord.js - Imagine an app
Created by UnNainTrue on 4/5/2024 in #djs-questions
The image is not sent
Oh nan I had not seen this guide
27 replies
DIAdiscord.js - Imagine an app
Created by UnNainTrue on 4/5/2024 in #djs-questions
The image is not sent
Look, I don't know, like I told you, I don't know JS. I was just trying to make a bot that works with the means at my disposal.
27 replies
DIAdiscord.js - Imagine an app
Created by UnNainTrue on 4/5/2024 in #djs-questions
The image is not sent
Ah well no I tried with
new: AttachmentBuilder('./welcome_image.png', { name: 'welcome_image.png' }), but it doesn't work
27 replies
DIAdiscord.js - Imagine an app
Created by UnNainTrue on 4/5/2024 in #djs-questions
The image is not sent
Ho okey I think I just understood
27 replies
DIAdiscord.js - Imagine an app
Created by UnNainTrue on 4/5/2024 in #djs-questions
The image is not sent
Can you just tell me if my reasoning is right please?
27 replies
DIAdiscord.js - Imagine an app
Created by UnNainTrue on 4/5/2024 in #djs-questions
The image is not sent
If I've understood correctly, all I have to do is attachment://${attachment.name}`); right?
27 replies
DIAdiscord.js - Imagine an app
Created by UnNainTrue on 4/5/2024 in #djs-questions
The image is not sent
I'm sorry I don't know the JS actually the code given was generated via chatGPT
27 replies
DIAdiscord.js - Imagine an app
Created by UnNainTrue on 4/5/2024 in #djs-questions
The image is not sent
const welcomeChannelId = '1221463992480960605'; // ID du canal de bienvenue
const backgroundImage = './assets/background.png';

module.exports = {
name: Discord.Events.GuildMemberAdd,
async run(client, member) {
try {
console.log("Début de la génération de l'image...");
const canvas = createCanvas(800, 400);
const ctx = canvas.getContext("2d");
const background = await loadImage(backgroundImage);
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);

ctx.font = "36px Arial";
ctx.fillStyle = "#ffffff";
ctx.fillText(`Bienvenue, ${member.user.username} !`, 50, 50);

const avatar = await loadImage(member.user.displayAvatarURL({ extension: 'jpg', size: 128 }));
ctx.drawImage(avatar, 50, 100, 100, 100);

const buffer = canvas.toBuffer("image/png");
console.log("Image générée avec succès.");

console.log("Début de l'enregistrement de l'image sur le disque...");
await fs.promises.writeFile("./welcome_image.png", buffer);
console.log("Image enregistrée avec succès.");

console.log("Tentative d'envoi de l'image sur Discord...");
const welcomeChannel = client.channels.cache.get(welcomeChannelId);
if (welcomeChannel) {
console.log("Canal de bienvenue trouvé. Tentative d'envoi de l'image...");
await welcomeChannel.send(`Bienvenue ${member.user} !`, {
files: [{ attachment: './welcome_image.png' }] // Assurez-vous que le chemin est correct
});
console.log("Image envoyée avec succès sur Discord.");
} else {
console.error("Canal de bienvenue introuvable.");
}
} catch (error) {
console.error("Une erreur s'est produite :", error);
}
},
};
const welcomeChannelId = '1221463992480960605'; // ID du canal de bienvenue
const backgroundImage = './assets/background.png';

module.exports = {
name: Discord.Events.GuildMemberAdd,
async run(client, member) {
try {
console.log("Début de la génération de l'image...");
const canvas = createCanvas(800, 400);
const ctx = canvas.getContext("2d");
const background = await loadImage(backgroundImage);
ctx.drawImage(background, 0, 0, canvas.width, canvas.height);

ctx.font = "36px Arial";
ctx.fillStyle = "#ffffff";
ctx.fillText(`Bienvenue, ${member.user.username} !`, 50, 50);

const avatar = await loadImage(member.user.displayAvatarURL({ extension: 'jpg', size: 128 }));
ctx.drawImage(avatar, 50, 100, 100, 100);

const buffer = canvas.toBuffer("image/png");
console.log("Image générée avec succès.");

console.log("Début de l'enregistrement de l'image sur le disque...");
await fs.promises.writeFile("./welcome_image.png", buffer);
console.log("Image enregistrée avec succès.");

console.log("Tentative d'envoi de l'image sur Discord...");
const welcomeChannel = client.channels.cache.get(welcomeChannelId);
if (welcomeChannel) {
console.log("Canal de bienvenue trouvé. Tentative d'envoi de l'image...");
await welcomeChannel.send(`Bienvenue ${member.user} !`, {
files: [{ attachment: './welcome_image.png' }] // Assurez-vous que le chemin est correct
});
console.log("Image envoyée avec succès sur Discord.");
} else {
console.error("Canal de bienvenue introuvable.");
}
} catch (error) {
console.error("Une erreur s'est produite :", error);
}
},
};
27 replies