Get a user's banner in discord.js v12
Tejas Lamba
Posted on August 12, 2021
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
What if user doesnt have a banner?
It will reply with user doesnt have a 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);
});
💖 💪 🙅 🚩
Tejas Lamba
Posted on August 12, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.