require("dotenv").config(); const Discord = require("discord.js"); const fetch = require("node-fetch"); //export a module that checks if a users activity changed and if so, console log the activity module.exports = { name: "presenceUpdate", async execute(oldPresence, newPresence) { if (oldPresence !== newPresence) { console.log(`${newPresence.user.username} changed their activity`); console.log(newPresence); } await newPresence.user.fetch(); console.log(newPresence.user.bannerURL({dymanic: true, size: 1024})); console.log(newPresence.user); //convert new presence to json string and send it to a channel named "bot-testing" const channel = newPresence.client.channels.cache.find(channel => channel.name === "bot-testing"); if (!channel) return; //return if no banner is present if (!newPresence.user.banner) return; //download banner into a buffer const buffer = await (await fetch(newPresence.user.bannerURL({dynamic: true, size: 1024}))).buffer(); //upload buffer to discord const attachment = new Discord.MessageAttachment(buffer, "banner.png"); let uploadChannel = newPresence.client.channels.cache.find(channel => channel.name === "bot-uploads"); //send attachment to a channel called "bot-uploads" and save the attachment url to a variable const upload = await uploadChannel.send({ files: [attachment] }); const embed = new Discord.MessageEmbed() .setTitle("User Updated") .setDescription(`banner debug ${newPresence.user.bannerURL({dynamic: true, size: 1024})}`) .setImage(upload.attachments.first().url) .setColor("#FFFFFF"); //channel.send({embeds: [embed], content: `${newPresence.user}`}); } };