import fetch from "node-fetch";
async function updateBanner() {
const BOT_TOKEN = "";
try {
const response = await fetch("https://discord.com/api/v10/users/@me", {
method: "PATCH",
headers: {
Authorization:
`Bot ${BOT_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ banner: "data:image/png;base64..." }),
});
const data = await response.json();
console.log(data);
} catch (error) {
console.error("Error:", error);
}
}
updateBanner();
Thanks to @fox3000foxy for sharing snippet.
- Put your app's token on "BOT_TOKEN" variable.
- Use a converter, such as: https://ezgif.com/image-to-datauri/
- Replace the banner field by the data url of your banner.
node file.js
The code I used is for "module" type projects. Go to your package.json file and add: