edit pbt message

This commit is contained in:
Louis Mazin 2026-07-11 21:47:49 +02:00
parent b729ac60de
commit 97f47b7adc
2 changed files with 2 additions and 36 deletions

View File

@ -1,29 +1,6 @@
const { SlashCommandBuilder } = require('discord.js');
const axios = require('axios');
const programMessage = require("./programMessage.json")
const getDownloadCount = async () => {
try {
const response = await axios.get('https://api.github.com/repos/LouisMazin/Palworld_Breeding_Tree/releases', {
headers: {
'Accept': 'application/vnd.github.v3+json',
'User-Agent': 'Palworld-Discord-Bot'
}
});
let totalDownloads = 0;
for (const asset of response.data[0].assets) {
totalDownloads += asset.download_count;
}
return totalDownloads;
} catch (error) {
console.log('Erreur lors de la récupération du nombre de téléchargements:', error.message);
return null;
}
};
module.exports = {
data: new SlashCommandBuilder()
.setName('pbt')
@ -34,19 +11,7 @@ module.exports = {
.setRequired(false)),
async execute(interaction) {
const user = interaction.options.getUser('utilisateur');
const downloadCount = await getDownloadCount();
// Clone the message to avoid modifying the original
const message = JSON.parse(JSON.stringify(programMessage));
// Add download count to the embed description
if (downloadCount !== null) {
const actual = downloadCount.toString();
let next = (downloadCount + 1).toString();
const lastNumber = actual[actual.length - 1];
next += next=='1' ? "ère" : "ème";
message.embeds[0].description = message.embeds[0].description.replace("X", actual).replace("Y", next);
}
message.content = user ? "||<@"+user.id+">||" : "";
await interaction.reply(message);
},

View File

@ -4,13 +4,14 @@
"embeds": [
{
"id": 313857863,
"description": "# **LE PROGRAMME DE LOUIS**\n\n## Merci de faire confiance à mon travail !:heart:\n\n### Il y a déjà X personnes sur la dernière version :\n### -> soit la Y ! :wink:\n### - Windows : [Github](https://www.github.com/LouisMazin/Palworld_Breeding_Tree/releases/latest) \n### - Si tu n'as pas Windows : [Google Sheet](https://docs.google.com/spreadsheets/d/1LkY9d6fbXS77c6P6A3uTKhdNxzEn86TLtdlemA4bUe8/edit?usp=sharing)",
"description": "# **LE PROGRAMME DE LOUIS**\n\n## Merci d'avoir fait confiance à mon travail !:heart:\n\n### Malheureusement cette application ne sera plus disponible, et plus mise à jour.\n### Toutes les informations sont [ici](https://discord.com/channels/1068240252092813373/1253054206424649822/1520122821047619685)",
"color": 2326507,
"fields": []
}
],
"components": [],
"actions": {},
"flags": 0,
"username": "Couteau Suisse",
"avatar_url": "https://srv.latostadora.com/designall.dll/couteau-suisse---dessin-drole-sketchy--i:141385141697014138520;d:1416970;w:520;b:FFFFFF;m:1.jpg"
}