Discord API Improvement

Comments

2 comments

  • christy hernandez

    Hello ny-stateofhealth.comKaden L Harbin,

    As of my last update, Discord has not provided a public API endpoint for bots to fetch a user’s guild-specific banner. This feature is available for users with Nitro to personalize their profiles, but the ability for bots to retrieve this information is not officially supported.

    However, developers often find creative workarounds for such limitations. For instance, some have used unofficial methods to retrieve user banners by making direct requests to Discord’s API endpoints. This involves using the user’s ID to construct a URL that points to the banner image. Here’s a simplified example of how it might be done.

    const fetch = require('node-fetch');

    async function getUserGuildBanner(userId) {
       const response = await fetch(`https://discord.com/api/v8/users/${userId}`, {
           method: 'GET',
           headers: {
               Authorization: `Bot ${yourBotToken}`
           }
       });

       if(response.ok) {
           const data = await response.json();
           const bannerHash = data.banner;

           if(bannerHash) {
               const format = bannerHash.startsWith('a_') ? 'gif' : 'png';
               const bannerUrl = `https://cdn.discordapp.com/banners/${userId}/${bannerHash}.${format}`;
               return bannerUrl;
           }
       }

       return null; // No banner found
    }

    Please note that this is an unofficial method and may not always work if Discord changes their API. It’s also important to respect Discord’s terms of service when using their API, even unofficially.

    For the latest updates or changes, you should check the official Discord Developer Documentation or the Discord API server where announcements and discussions about the API take place. If you believe this feature would be beneficial, you can also provide feedback to Discord through their official channels or community forums.

    Best Regards,
    ny-stateofhealth.com
     

    0
  • Zoya

    For instance, some have used unofficial methods to retrieve user banners by making direct requests to Discord’s API endpoints. This involves using the user’s ID to construct a URL that points to the banner image. Here’s a simplified example of how it might be done branded travel mugs.

    0

Please sign in to leave a comment.