The issue with the types is that when resolve() was called, it would return void, which you couldn't test if it was authenticated. To fix this, we return resolve(true), returning that the server was authenticated.
//rcon.ts
response = response.concat(decodedPacket.body.replace(/\n$/, '\n')) // remove last line break
if (response.includes(`command "${body}"`)) { // Never returns true, the response will not have command prefixed
this.connection.removeListener('data', onData)
resolve(response)
}
The response never resolving was an issue with checking if the string response contained the prefixed word command. This is no longer the case as it seems with my testing, and just returns the raw response. To fix this, we just check if there is a response, and to go ahead with the resolving of the response.
Also, added a comment to explain why we're doing this check so it makes sense why it's being used.
//rcon.ts
response = response.concat(decodedPacket.body.replace(/\n$/, '\n')) // remove last line break
if (response) { // Will resove if there's a response length
this.connection.removeListener('data', onData)
resolve(response)
}
I will be testing this actively as I rely on this package to do all my rcon communication, and since it'll be written in typescript, types are a must.
This PR fixes an issue
authenticate
not building and the response never resolving the server's response.The issue with the types is that when
resolve()
was called, it would return void, which you couldn't test if it was authenticated. To fix this, we returnresolve(true)
, returning that the server was authenticated.The response never resolving was an issue with checking if the string
response
contained the prefixed wordcommand
. This is no longer the case as it seems with my testing, and just returns the raw response. To fix this, we just check if there is a response, and to go ahead with the resolving of the response.Also, added a comment to explain why we're doing this check so it makes sense why it's being used.
I will be testing this actively as I rely on this package to do all my rcon communication, and since it'll be written in typescript, types are a must.