From f4be8d32c80d2b975b8ea59e3488cd1084269856 Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Sat, 27 Mar 2021 17:17:16 +0530 Subject: Adds Fallbacks for loadout retrievals --- src/main.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main.js b/src/main.js index f1df54b..5d0f95e 100644 --- a/src/main.js +++ b/src/main.js @@ -195,16 +195,20 @@ async function getCodMLoadOut(message, args) { view: "Grid view", filterByFormula: `({cod_username} = '${args[0]}')` }).eachPage(function page(records, fetchNextPage) { - records.forEach((record) => { - const loadOutMessage = new MessageEmbed() + if (records && records.length > 0) { + records.forEach((record) => { + const loadOutMessage = new MessageEmbed() .setTitle(`Loadout of ${codUserName} : ${record.get('cod_match_type')}`) .addField('Weapon Name', record.get('cod_weapon_name'),true) .addField('Weapon Type', record.get('cod_weapon_type'),true) .addField('Attachments', record.get('cod_weapon_attachments'),true) .setColor("RANDOM"); - message.channel.send(loadOutMessage); - }); - fetchNextPage(); + message.channel.send(loadOutMessage); + }); + fetchNextPage(); + } else { + message.channel.send(`No Loadout found for ***${codUserName}***`); + } }, function done(err) { if (err) { console.error(err); return; } -- cgit v1.2.3