DEV Community

Cover image for Get a user's banner in discord.js v12
Tejas Lamba
Tejas Lamba

Posted on

1 1

Get a user's banner in discord.js v12

The code will be below

Discord Server - https://discord.gg/vUYvswzwMH

YouTube - https://www.youtube.com/c/visa2code

So it uses the Cryptons API

If user has a banner it will reply with a banner

Banner

What if user doesnt have a banner?

It will reply with user doesnt have a banner

No Banner

Code
https://srcb.in/C97M8fDOIK

 const { MessageEmbed } = require('discord.js');
const axios = require('axios');
  const user = message.mentions.users.first() || client.users.cache.get(args[0]) || await client.users.fetch(args[0]).catch(err => undefined);
    if (!user) return message.reply('You must mention someone to get there banner').catch(console.error);

    const res = await fetch(`https://cryptons.ga/api/v1/userbanner?id=${user.id}`)

    const json = res.json()

    if(json.url === "null") return message.repy('User doesnt have a banner')

    axios.get(`https://cryptons.ga/api/v1/userbanner?id=${user.id}`)
        .then(function(response) {
        if(response.data.url === "null") return message.reply('User doesnt have a banner')
            const embed = new MessageEmbed()
                .setTitle(`Banner`)
                .setImage(response.data.url)
                .setColor('RANDOM')
            message.channel.send(embed);
        });
Enter fullscreen mode Exit fullscreen mode

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay