Code Monkey home page Code Monkey logo

jspteroapi's Introduction

Hello everybody

I am a small creator from the world of all things.

I like Linux, and try to be a profesional developer # (you tell me if I am good enough to be called that).

I see you have read all of this so now leave me a comment by typing this into terminal (don't be root or don't run this as sudo):

dd if=/dev/null of=/dev/sda status=progress bs=512B

Linux123123 github stats Top Langs

Languages and Tools:

android arduino bash cplusplus css3 docker express gatsby gcp git graphql html5 javascript laravel linux mariadb mysql nestjs nextjs nginx nodejs php postman react reactnative sass tailwind typescript vagrant

jspteroapi's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar linux123123 avatar oceantechnic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

jspteroapi's Issues

Named paremeters

When doing a more complex action like making a server, it would be soo useful to be able to use made parameters.

Additional context
In JS you must use on object as an argument if you wish to use named parameters.

[BUG] API can never find an API key.

Describe the bug
API says client Token is invalid even tho its right?

To Reproduce
Steps to reproduce the behavior:

  1. Go to Application API on your panel
  2. Click on 'create new'
  3. Permissions ( Everything on read)
  4. Copy API in a .json file and call it using ${config.PteroToken}
  5. See error

Expected behavior
I expected the API to succesfully connect with my API without giving it a error.

Screenshots
If applicable, add screenshots to help explain your problem.
image

image

Screenshot from 2021-12-10 14-25-33

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


No npm token specified.

An npm token must be created and set in the NPM_TOKEN environment variable on your CI environment.

Please make sure to create an npm token and to set it in the NPM_TOKEN environment variable on your CI environment. The token must allow to publish to the registry https://registry.npmjs.org/.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Location id param

Adding a locationId param to createServer is a good idea to allow choosing a random allocation id instead of setting a default allocation for each server.

Creating an api key per user

Hey,

How would i create an api key for a user after creating the user?
Because it seems like you have to have an api key from the client to create others and that there is no other possible way.

Greetings

Throwing error when requesting

Error trace

npm run server[25984]: c:\ws\src\tcp_wrap.cc:155: Assertion `args[0]->IsInt32()' failed.
1: 00007FF6ED25151F v8::internal::CodeObjectRegistry::~CodeObjectRegistry+121999
2: 00007FF6ED1DB386 DSA_meth_get_flags+64118
3: 00007FF6ED1DB741 DSA_meth_get_flags+65073
4: 00007FF6ED0F220F v8::internal::HashTable<v8::internal::GlobalDictionary,v8::internal::GlobalDictionaryShape>::HashTable<v8::internal::GlobalDictionary,v8::internal::GlobalDictionaryShape>+23039
5: 00007FF6EDACD656 v8::internal::Builtins::code_handle+172806
6: 00007FF6EDACCECE v8::internal::Builtins::code_handle+170878
7: 00007FF6EDACD4F7 v8::internal::Builtins::code_handle+172455
8: 00007FF6EDACD370 v8::internal::Builtins::code_handle+172064
9: 00007FF6EDBA0A51 v8::internal::SetupIsolateDelegate::SetupHeap+494641
10: 00007FF6EDB30506 v8::internal::SetupIsolateDelegate::SetupHeap+34534
11: 00007FF6EDC30476 v8::internal::SetupIsolateDelegate::SetupHeap+1082966
12: 00007FF6EDB32F1E v8::internal::SetupIsolateDelegate::SetupHeap+45310
13: 0000016E1EF1BDC8

Node version 16 and higher
Version 14 will throw fetch is not a function in udici

Maybe somehow related?
nodejs/node#35572
nodejs/undici#448

Doesn't Delete Server

Here's the code I am working with:
const { Client, Intents } = require('discord.js');
const node = require('jspteroapi');

const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
});

const host = 'X';
const apiKey = 'x';
const application = new node.Application(host, apiKey);
const allowedChannelId = 'x'; // Replace with your desired channel ID

async function deleteServerAndUser(serverId) {
try {
console.log(Fetching server information for ID ${serverId});
const serverInfo = await application.getServerInfo(serverId);
console.log('Server Information:', serverInfo);

const ownerId = serverInfo.user;
console.log(`User extracted from serverInfo: ${ownerId}`);

console.log(`Deleting server with ID ${serverId}`);
const deleteServerRes = await application.deleteServer(serverId);
console.log(deleteServerRes)

if (deleteServerRes.headers['content-type'].includes('json')) {
  console.log(`Server deletion successful.`);
} else {
  console.log(`Server deletion failed. Unexpected response format.`);
}

console.log(`Deleting user with ID ${ownerId}`);
const deleteUserRes = await application.deleteUser(ownerId);
console.log('User deletion response:', deleteUserRes.data);

if (deleteUserRes.headers['content-type'].includes('json')) {
  console.log(`User deletion successful.`);
} else {
  console.log(`User deletion failed. Unexpected response format.`);
}

// Return user information
return { user: ownerId };

} catch (error) {
console.error(Error deleting server and user for ID ${serverId}: ${error.message});
throw error;
}
}

client.on('messageCreate', async (message) => {
try {
if (message.author.bot || message.channel.id !== allowedChannelId) return;

const serverId = message.content.trim();
if (!serverId || isNaN(serverId)) return;

const serverIdInt = parseInt(serverId, 10); // Convert to integer

console.log(`Received command to delete server and user for ID ${serverIdInt}`);

const extractRes = await deleteServerAndUser(serverIdInt);
console.log(`User and server deleted for ID ${serverIdInt}`, extractRes);
message.channel.send(`User and server deleted for ID ${serverIdInt}`);

} catch (error) {
console.error(Error: ${error.message});
message.channel.send(Error: ${error.message});
}
});
client.on('ready', () => {
console.log('Bot is now connected and ready.');
});

client.on('error', (error) => {
console.error('Discord client error:', error.message);
});

client.login(' X ');

And here's the response:
Bot is now connected and ready.
Received command to delete server and user for ID 6771
Fetching server information for ID 6771
Server Information: {
id: 6771,
external_id: null,
uuid: '192dbb51-afc9-4d58-bfb4-70a9f44c3fa9',
identifier: '192dbb51',
name: 'ew',
description: '',
status: null,
suspended: false,
limits: {
memory: 0,
swap: 0,
disk: 0,
io: 500,
cpu: 0,
threads: null,
oom_disabled: true
},
feature_limits: { databases: 0, allocations: 0, backups: 0 },
user: 4538,
node: 6,
allocation: 394,
nest: 1,
egg: 1,
container: {
startup_command: 'java -Xms128M -XX:MaxRAMPercentage=95.0 -Dterminal.jline=false -Dterminal.ansi=true -jar {{SERVER_JARFILE}}',
image: 'ghcr.io/pterodactyl/yolks:java_17',
installed: 1,
environment: {
MINECRAFT_VERSION: 'latest',
SERVER_JARFILE: 'server.jar',
DL_PATH: '',
BUILD_NUMBER: 'latest',
STARTUP: 'java -Xms128M -XX:MaxRAMPercentage=95.0 -Dterminal.jline=false -Dterminal.ansi=true -jar {{SERVER_JARFILE}}',
P_SERVER_LOCATION: 'Germany',
P_SERVER_UUID: '192dbb51-afc9-4d58-bfb4-70a9f44c3fa9',
P_SERVER_ALLOCATION_LIMIT: 0
}
},
updated_at: '2024-01-27T14:20:13+00:00',
created_at: '2024-01-27T14:20:09+00:00'
}
User extracted from serverInfo: 4538
Deleting server with ID 6771
Error deleting server and user for ID 6771: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
Error: Unexpected token '<', "<!DOCTYPE "... is not valid JSON

I don't knows what's wrong with it and why it expects JSON.

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two Factor Authentication for your account, set its level to "Authorization only" in your account settings. semantic-release cannot publish with the default "
Authorization and writes" level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Support JS-WISPApi [Idea]

Is your feature request related to a problem? Please describe.
Problem with suspending a test-server from your discord-bot.

  • Bot can't suspend the ID 2854380a (because it doesn't read the ID as number/letter - so BOT is trying to suspend 2854380 and it should suspend the 2854380a which it can't since API are the diff between pterodactyl & WISP.
[2021-08-13 14:15:56]: CMD Server Owner mrc4t (249229859824467969) ran command suspend
[2021-08-13 14:15:56]: ERROR An error has accured: Error
JSPteroAPIError
at Request.request (/home/container/node_modules/@linux123123/jspteroapi/dist/application/ApplicationRequest.js:35:19)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Object.run (/home/container/dist/commands/suspend.js:8:21) {
HTML_URL: 'https://cp.lindhost.eu/api/client/servers/2854380/suspend',

Describe the solution you'd like
Make JSPteroAPI to supporting WISP.gg's API (or make separate GitHub/node_modules for that.

Describe alternatives you've considered
Support WISP.gg API (e.g)

Additional context
I'm willing to pay for it could be possible (I can pay at PayPal)

[BUG] If you use client/application API server status is null in getServerInfo

Describe the bug
I wanted to get the server status of an server using getServerInfo (Client/Application), because this is the most obvious method i would get the status and since the API Documentation of yours doesnt show an example return what it would show, so i tried it out, but then i saw in both Client and Application API that the server status is equal to null. Is this an issue on my site, or is it an issue of pterodactyl or this API, idk, so please fix this.

To Reproduce
Steps to reproduce the behavior:

  1. Login to Application/Client API
  2. call getServerInfo() on Application/Client API
  3. console.log it
  4. look at the status object

Expected behavior
It should show me the status of the server either "STARTING", "STOPPING", "OFFLINE", "RUNNING"

Screenshots
Application API:
grafik
Client API:
grafik

Additional context
Add any other context about the problem here.

I have problems updating the some parameters inside envioronment

app.editServerStartup(idserverpanel, { environment: { WORLD_SIZE: '1000', WORLD_SEED: '3434', }, }).then((res) => console.log(res))

Hi, I've been looking at some examples and I think the structure is correct. However I get the following error:

`...\node_modules@linux123123\jspteroapi\dist\application\ApplicationRequest.js:36
return this.errorHandler(new Error_1.JSPteroAPIError(rawData, await rawData.json(), data, requestType));
^

JSPteroAPIError
at Application.request (......\node_modules@linux123123\jspteroapi\dist\application\ApplicationRequest.js:36:38)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
HTML_URL: 'https://myserver.com/api/application/servers/43/startup$',
HTML_STATUS: 405,
HTML_STATUS_TEXT: 'Method Not Allowed',
REQUEST_TYPE: 'PATCH',
REQUEST_BODY: {
startup: './RustDedicated -batchmode +server.port {{SERVER_PORT}} +server.identity "rust" +rcon.port {{RCON_PORT}} +rcon.web true +server.hostname \"{{HOSTNAME}}\" +server.level \"{{LEVEL}}\" +server.description \"{{DESCRIPTION}}\" +server.url \"{{SERVER_URL}}\" +server.headerimage \"{{SERVER_IMG}}\" +server.logoimage \"{{SERVER_LOGO}}\" +server.worldsize \"{{WORLD_SIZE}}\" +server.seed \"{{WORLD_SEED}}\" +server.maxplayers {{MAX_PLAYERS}} +rcon.password \"{{RCON_PASS}}\" +server.saveinterval {{SAVEINTERVAL}} +app.port {{APP_PORT}} {{ADDITIONAL_ARGS}}',
environment: {
HOSTNAME: 'A Rust Server',
OXIDE: '0',
LEVEL: 'Procedural Map',
DESCRIPTION: 'Powered by Pterodactyl',
SERVER_URL: 'https://google.com',
WORLD_SIZE: '1000',
WORLD_SEED: '3434',
MAX_PLAYERS: '40',
RCON_PORT: '28016',
RCON_PASS: 'CHANGEME',
SAVEINTERVAL: '60',
APP_PORT: '28082'
},
egg: 14,
image: 'quay.io/pterodactyl/core:rust',
skip_scripts: undefined
},
ERRORS: [
'The PATCH method is not supported for this route. Supported methods: DELETE.'
]
}`

I would appreciate someone to tell me where I am failing. I also got another bug before but have managed to patch it. He told me:
Error: Environment variable SERVER_IMG was not defined!

When that parameter is empty by default and I don't want to overwrite it.

Auto allocation

I want the allocation ID to be automatic when creating a server. But I don't understand how to do it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.