This commit is contained in:
2024-10-15 21:37:55 +00:00
parent e677a45ecd
commit 7302b27dc3
10 changed files with 233 additions and 28 deletions

View File

@@ -77,5 +77,29 @@ export default function files(pterodactyl: any) {
console.error("Error fetching data:", error);
}
},
async saveContent(filename: string, content: string) {
try {
const response = await fetch(
`${process.env.NEXT_PUBLIC_URL}/api/client/servers/${pterodactyl.server_id}/files/write?file=${filename}`,
{
method: "POST",
headers: await pterodactyl.helpers.authHeader("application/text"),
body: "'test'",
}
);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
return data;
} catch (error) {
console.error("Error fetching data:", error);
}
},
async createFile(filename: string) {
this.saveContent(filename, "");
},
};
}