mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-20 21:41:17 +02:00
ajout de commande gestion
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
const axios = require('axios');
|
||||
|
||||
module.exports = {
|
||||
name: 'create',
|
||||
description: 'Crée un emoji',
|
||||
async execute(message, args, client) {
|
||||
if (!args.length) {
|
||||
return message.channel.send({ content: "Veuillez spécifier un émoji." });
|
||||
}
|
||||
|
||||
for (const rawEmoji of args) {
|
||||
// Si rawEmoji est un identifiant d'emoji Discord valide
|
||||
if (rawEmoji.match(/^\d+$/)) {
|
||||
const emoji = client.emojis.cache.get(rawEmoji);
|
||||
if (!emoji) {
|
||||
return message.channel.send({ content: "L'argument fourni n'est pas un identifiant d'emoji valide." });
|
||||
}
|
||||
|
||||
const extension = emoji.animated ? ".gif" : ".png";
|
||||
const url = `https://cdn.discordapp.com/emojis/${emoji.id}${extension}`;
|
||||
|
||||
// Download the emoji image
|
||||
try {
|
||||
console.log('Téléchargement de l\'image de l\'emoji...');
|
||||
const response = await axios.get(url, { responseType: 'arraybuffer' });
|
||||
console.log(response.data); // Ajoutez ceci pour vérifier le contenu de response.data
|
||||
const buffer = Buffer.from(response.data, 'binary');
|
||||
|
||||
// Create the emoji
|
||||
message.guild.emojis.create(buffer, emoji.name)
|
||||
.then(createdEmoji => message.channel.send({ content: `Emoji ${createdEmoji} créé avec succès.` }))
|
||||
.catch(error => message.channel.send({ content: `Une erreur s'est produite lors de la création de l'emoji : ${error}` }));
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return message.channel.send({ content: `Une erreur s'est produite lors du téléchargement de l'image de l'emoji : ${error}` });
|
||||
}
|
||||
} else {
|
||||
// Si rawEmoji est un emoji Unicode
|
||||
message.guild.emojis.create(rawEmoji, { reason: 'Création d\'emoji à partir d\'un emoji Unicode' })
|
||||
.then(createdEmoji => message.channel.send({ content: `Emoji ${createdEmoji} créé avec succès.` }))
|
||||
.catch(error => {
|
||||
console.error(`Erreur lors de la création de l'emoji : ${error.message}`);
|
||||
message.channel.send({ content: `Une erreur s'est produite lors de la création de l'emoji : ${error.message}` });
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user