From dfe2435013436040aa6a60d4b70e01fb7204d271 Mon Sep 17 00:00:00 2001 From: 404invalid-user Date: Mon, 6 Sep 2021 00:43:41 +0100 Subject: [PATCH] fixed discord id not working (untested) --- src/bot/commands/fun/fivem.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/bot/commands/fun/fivem.js b/src/bot/commands/fun/fivem.js index 812682d..db14981 100644 --- a/src/bot/commands/fun/fivem.js +++ b/src/bot/commands/fun/fivem.js @@ -22,7 +22,7 @@ module.exports = { serverEmbed.addField(`__**players:**__`, `${dynamicResponse.clients}/${dynamicResponse.sv_maxclients}`, true) - }).on('error', function(error) { + }).on('error', function (error) { console.log('error: ' + error) }) }) @@ -87,7 +87,7 @@ module.exports = { body += chunk }) - result.on('end', () => { + result.on('end', async () => { var response = JSON.parse(body) if (response.length == 0 || response.length < 0) { playersEmbed.addField("__info__", `no one is on the server`) @@ -95,7 +95,13 @@ module.exports = { let i; for (i = 0; i < response.length; i++) { - playersEmbed.addField(`player ${i}:`, `__**name:**__ ${response[i].name} \n __**discord:**__ <@!${response[i].identifiers[3].replace('discord:', '')}> \n __**fiveM id:**__ ${response[i].id} \n __**ping:**__ ${response[i].ping} \n`) + let discordID = ''; + await response[i].identifiers.forEach(id => { + if (id.includes('discord:')) { + discordID = id.replace('discord:', ''); + } + }); + playersEmbed.addField(`player ${i}:`, `__**name:**__ ${response[i].name} \n __**discord:**__ <@!${discordID}> \n __**fiveM id:**__ ${response[i].id} \n __**ping:**__ ${response[i].ping} \n`) } if (i == response.length) { try { @@ -106,7 +112,7 @@ module.exports = { } } - }).on('error', function(error) { + }).on('error', function (error) { console.log('error: ' + error) }) }) @@ -116,4 +122,4 @@ module.exports = { } } } -} \ No newline at end of file +}