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
Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\a1989\Desktop\Banner Discord\node_modules\node-fetch\src\index.js from C:\Users\a1989\Desktop\Banner Discord\file.js not supported.
Instead change the require of index.js in C:\Users\a1989\Desktop\Banner Discord\file.js to a dynamic import() which is available in all CommonJS modules.
at Object. (C:\Users\a1989\Desktop\Banner Discord\file.js:1:15) {
code: 'ERR_REQUIRE_ESM'
}