mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-03 23:36:35 +02:00
banner command
This commit is contained in:
@@ -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] });
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user