edit pbt message
This commit is contained in:
parent
b729ac60de
commit
97f47b7adc
@ -1,29 +1,6 @@
|
|||||||
const { SlashCommandBuilder } = require('discord.js');
|
const { SlashCommandBuilder } = require('discord.js');
|
||||||
const axios = require('axios');
|
|
||||||
const programMessage = require("./programMessage.json")
|
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 = {
|
module.exports = {
|
||||||
data: new SlashCommandBuilder()
|
data: new SlashCommandBuilder()
|
||||||
.setName('pbt')
|
.setName('pbt')
|
||||||
@ -34,18 +11,6 @@ module.exports = {
|
|||||||
.setRequired(false)),
|
.setRequired(false)),
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
const user = interaction.options.getUser('utilisateur');
|
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+">||" : "";
|
message.content = user ? "||<@"+user.id+">||" : "";
|
||||||
await interaction.reply(message);
|
await interaction.reply(message);
|
||||||
|
|||||||
@ -4,13 +4,14 @@
|
|||||||
"embeds": [
|
"embeds": [
|
||||||
{
|
{
|
||||||
"id": 313857863,
|
"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,
|
"color": 2326507,
|
||||||
"fields": []
|
"fields": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"components": [],
|
"components": [],
|
||||||
"actions": {},
|
"actions": {},
|
||||||
|
"flags": 0,
|
||||||
"username": "Couteau Suisse",
|
"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"
|
"avatar_url": "https://srv.latostadora.com/designall.dll/couteau-suisse---dessin-drole-sketchy--i:141385141697014138520;d:1416970;w:520;b:FFFFFF;m:1.jpg"
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user