From 196c2e4897b1f71c2752eb2faa09c4ba024d94b1 Mon Sep 17 00:00:00 2001 From: Tutur33 Date: Fri, 16 Feb 2024 23:53:47 +0100 Subject: [PATCH] banner command --- commands/utils/banner.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 commands/utils/banner.js diff --git a/commands/utils/banner.js b/commands/utils/banner.js new file mode 100644 index 0000000..f22855a --- /dev/null +++ b/commands/utils/banner.js @@ -0,0 +1,38 @@ +const fetch = require('node-fetch'); +const { EmbedBuilder } = require('discord.js'); + +module.exports = { + name: 'banner', + description: 'Affiche la bannière d\'un utilisateur', + emote: '🔍', + utilisation: 'banner <@user>', + category: 'utils', + + async execute(message, args, client) { + const user = message.mentions.users.first() || message.author; + + const response = await fetch(`https://discord.com/api/users/${user.id}`, { + method: 'GET', + headers: { + Authorization: `Bot ${message.client.token}` + } + }); + const data = await response.json(); + + if (!data.banner) { + return message.reply('Cet utilisateur n\'a pas de bannière.'); + } + + const format = data.banner.startsWith('a_') ? 'gif' : 'png'; + + const bannerURL = `https://cdn.discordapp.com/banners/${user.id}/${data.banner}.${format}?size=2048`; + + const embed = new EmbedBuilder() + .setTitle(`Bannière de ${user.tag}`) + .setImage(bannerURL) + .setFooter({ text: `Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() }) + .setTimestamp(); + + message.channel.send({ embeds: [embed] }); + }, +}; \ No newline at end of file