4

Code Snippet for Adding Banner to Discord App

 6 months ago
source link: https://gist.github.com/Neodevils/eda4d97a395773e176142fbb4975f759
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

App Banner Code

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();

IMPORTANT!

Thanks to @fox3000foxy for sharing snippet.

  1. Put your app's token on "BOT_TOKEN" variable.
  2. Use a converter, such as: https://ezgif.com/image-to-datauri/
  3. Replace the banner field by the data url of your banner.
  4. node file.js

App Banner Image

image

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK