Add server version to state.raw and eslint
This commit is contained in:
parent
1007be3e21
commit
5820abe737
|
@ -7,19 +7,19 @@ export default class farmingsimulator extends Core {
|
|||
if (!this.options.token) throw new Error(`No token provided. You can get it from http://${this.options.host}:${this.options.port}/settings.html`)
|
||||
|
||||
const request = await this.request({
|
||||
url: `http://${this.options.host}:${this.options.port}/feed/dedicated-server-stats.xml?code=${this.options.token}`,
|
||||
responseType: 'text'
|
||||
})
|
||||
|
||||
const $ = cheerio.load(request, {
|
||||
xmlMode: true,
|
||||
url: `http://${this.options.host}:${this.options.port}/feed/dedicated-server-stats.xml?code=${this.options.token}`,
|
||||
responseType: 'text'
|
||||
})
|
||||
|
||||
const serverInfo = $('Server');
|
||||
const playerInfo = serverInfo.find('Slots');
|
||||
const $ = cheerio.load(request, {
|
||||
xmlMode: true
|
||||
})
|
||||
|
||||
state.name = serverInfo.attr('name');
|
||||
state.map = serverInfo.attr('mapName');
|
||||
const serverInfo = $('Server')
|
||||
const playerInfo = serverInfo.find('Slots')
|
||||
|
||||
state.name = serverInfo.attr('name')
|
||||
state.map = serverInfo.attr('mapName')
|
||||
state.numplayers = playerInfo.attr('numUsed')
|
||||
state.maxplayers = playerInfo.attr('capacity')
|
||||
|
||||
|
@ -31,11 +31,11 @@ export default class farmingsimulator extends Core {
|
|||
isAdmin: $(this).attr('isAdmin') === 'true',
|
||||
uptime: parseInt($(this).attr('uptime'), 10)
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
state.raw.mods = [];
|
||||
state.raw.mods = []
|
||||
$('Mod').each(function () {
|
||||
if ($(this).attr('name') !== undefined) {
|
||||
state.raw.mods.push({
|
||||
|
@ -43,12 +43,13 @@ export default class farmingsimulator extends Core {
|
|||
short_name: $(this).attr('name'),
|
||||
author: $(this).attr('author'),
|
||||
version: $(this).attr('version'),
|
||||
hash: $(this).attr('hash'),
|
||||
});
|
||||
hash: $(this).attr('hash')
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
state.raw.version = serverInfo.attr('version')
|
||||
|
||||
// TODO: Add state.raw
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue