···11-import { SlashCommandBuilder, EmbedBuilder } from "discord.js";
22-import fecthClientServerInfo from "../functions/fetchClientServerInfo.js";
33-// import axios from "axios";
11+import { SlashCommandBuilder } from "discord.js";
22+import axios from "axios";
4354export default {
65 data: new SlashCommandBuilder()
76 .setName("create-backup")
87 .setDescription("Create a new backup for a server")
98 .addStringOption((option) =>
1010- option.setName("server-id")
99+ option.setName("identifier")
1110 .setDescription("Your server identifier")
1211 .setRequired(true),
1312 ),
1413 async execute(interaction) {
1515- const serverId = interaction.options.get("server-id").value;
1616- const server = await fecthClientServerInfo(serverId);
1717- const embed = new EmbedBuilder()
1818- .setTitle(`Server: ${server.name}`)
1919- .setDescription("New embed for a serve")
2020- .setColor("Blurple")
2121- .setTimestamp();
1414+ const id = interaction.options.get("identifier").value;
1515+ let response;
1616+ try {
1717+ response = await axios.post(`/servers/${id}/backups`);
1818+ }
1919+ catch (error) {
2020+ console.log(error.response.data.errors);
2121+ return interaction.reply({ content: error.response.data.errors[0].detail, ephemeral: true });
2222+ }
22232323- return interaction.reply({ embeds: [embed] });
2424+ return interaction.reply(`Backup created successfuly with the name ${response.data.attributes.name}`);
2425 },
2526};
+2-2
src/commands/Help.js
···88 const embed = new EmbedBuilder()
99 .setTitle("Need some help?")
1010 .setDescription(`
1111- **PteroBot** give an access to control your server trough this discord commands. \n
1111+ **PteroBot** give an access to control your server trough discord commands. \n
1212 **/servers** : List all your servers \n
1313 **/server {identifier}** : Show you informations about your server, like CPU, RAM, DISK utilization or Update \n
1414 **/power {identifer} {state}** : Provide you a way to change a server state (start, stop, kill or restart) \n
1515 **/backups {identifier}** : Show all your server backups \n
1616 **/create-backup {identifier}** : Create a new backup for your (within the limit of available backups) \n
1717 \n
1818- If you want to support the bot development, please stared the github repository or contribute to it. https://github.com/Cosmeak/PteroBot
1818+ If you want to support bot development, please stars the github repository or contribute to it. https://github.com/Cosmeak/PteroBot
1919 `)
2020 .setTimestamp()
2121 .setColor("Blurple");