1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-17 20:30:58 -05:00

Fix /mp status and fetchPlayerData function

This commit is contained in:
toast-ts 2024-04-11 17:15:12 +10:00
parent 29bf036c91
commit 7e105f8a1e
2 changed files with 4 additions and 3 deletions

View File

@ -93,10 +93,10 @@ export default class MP {
if (!DSS) return console.log('Endpoint failed - status'); if (!DSS) return console.log('Endpoint failed - status');
DSS.server ? await interaction.reply({embeds: [new client.embed().setColor(client.config.embedColor).addFields( DSS.server ? await interaction.reply({embeds: [new client.embed().setColor(client.config.embedColor).addFields(
{name: 'Name', value: DSS.server?.name?.length < 1 ? '*`Offline`*' : `\`${DSS?.server?.name}\``}, {name: 'Name', value: `\`${DSS.server?.name.length > 0 ? DSS.server.name : 'Offline'}\``},
{name: 'Players', value: `${DSS?.slots.used}/${DSS?.slots.capacity}`}, {name: 'Players', value: `${DSS?.slots.used}/${DSS?.slots.capacity}`},
{name: 'Map', value: DSS?.server.mapName ?? 'Unavailable'} {name: 'Map', value: DSS.server?.mapName.length > 0 ? DSS.server.mapName : 'No map'}
).setFooter({text: `Version: ${DSS?.server?.version} | Time: ${`${('0'+Math.floor((DSS?.server.dayTime/3600/1000))).slice(-2)}:${('0'+Math.floor((DSS?.server.dayTime/60/1000)%60)).slice(-2)}`}`})]}) : null ).setFooter({text: `Version: ${DSS?.server?.version.length > 0 ? DSS?.server?.version : '0.0.0.0'} | Time: ${`${('0'+Math.floor((DSS?.server.dayTime/3600/1000))).slice(-2)}:${('0'+Math.floor((DSS?.server.dayTime/60/1000)%60)).slice(-2)}`}`})]}) : null
}, },
pallets: async()=>{ pallets: async()=>{
const DSS = await fetchData(client, interaction, choiceSelector) as FSData; const DSS = await fetchData(client, interaction, choiceSelector) as FSData;

View File

@ -57,6 +57,7 @@ export class MPServerSvc {
} }
async fetchPlayerData(serverName:string) { async fetchPlayerData(serverName:string) {
const server = await this.model.findOne({where: {serverName}}); const server = await this.model.findOne({where: {serverName}});
if (!server) return [];
return server.dataValues.playerData ??= []; return server.dataValues.playerData ??= [];
} }
async addServer(serverName:string, ip:string, code:string) { async addServer(serverName:string, ip:string, code:string) {