mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-10 19:04:21 +02:00
grand commit que tutur attend ( marche pas le raidmode en dev)
sinon il y a pleins de truc comme les anti raid , des coorectif ect
This commit is contained in:
+28
-16
@@ -1,6 +1,29 @@
|
||||
const fetch = require('node-fetch');
|
||||
const axios = require('axios');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
async function getUserBanner(user, message) {
|
||||
try {
|
||||
const response = await axios.get(`https://discord.com/api/users/${user.id}`, {
|
||||
headers: {
|
||||
Authorization: `Bot ${message.client.token}`
|
||||
}
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
|
||||
if (!data.banner) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const format = data.banner.startsWith('a_') ? 'gif' : 'png';
|
||||
const bannerURL = `https://cdn.discordapp.com/banners/${user.id}/${data.banner}.${format}?size=2048`;
|
||||
|
||||
return bannerURL;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
message.reply('Une erreur s\'est produite lors de la récupération des données de l\'utilisateur.');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
module.exports = {
|
||||
name: 'banner',
|
||||
aliases: ['bannière', 'banniere'],
|
||||
@@ -11,26 +34,15 @@ module.exports = {
|
||||
|
||||
async execute(message, args, client) {
|
||||
const user = message.mentions.users.first() || message.author;
|
||||
const bannerURL = await getUserBanner(user, message);
|
||||
|
||||
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.');
|
||||
if (!bannerURL) {
|
||||
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)
|
||||
.setImage(bannerURL || '')
|
||||
.setFooter({ text: `Demandé par ${message.author.tag}`, iconURL: message.author.displayAvatarURL() })
|
||||
.setTimestamp();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user