feat: Use async/await on attempt_protocols

This commit is contained in:
CosminPerRam 2023-11-05 23:50:43 +02:00
parent c264138e54
commit c49d463858

View file

@ -17,17 +17,20 @@ const gamedig = new GameDig(options)
const protocols = ['valve', 'gamespy1', 'gamespy2', 'gamespy3', 'goldsrc', 'minecraft', 'quake1', 'quake2', 'quake3', 'unreal2', 'valve']
protocols.forEach(protocol => {
gamedig.query({
...options,
debug: true,
type: `protocol-${protocol}`
})
.then(data => {
console.log(data)
const run = async () => {
for (const protocol of protocols) {
try {
const response = await gamedig.query({
...options,
debug: true,
type: `protocol-${protocol}`
})
console.log(response)
process.exit()
})
.catch(error => {
console.log(`Error on '${protocol}': ${error}`)
})
})
} catch (e) {
console.log(`Error on '${protocol}': ${e}`)
}
}
}
run().then(() => {})