aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIndrajith K L2021-03-27 17:17:16 +0530
committerIndrajith K L2021-03-27 17:17:16 +0530
commitf4be8d32c80d2b975b8ea59e3488cd1084269856 (patch)
tree2038604e16456ed4e027e81cf47a68652e53fa23 /src
parent6f07b57b89ff39d47279bc2ce451493701314212 (diff)
downloadradio-bot-f4be8d32c80d2b975b8ea59e3488cd1084269856.tar.gz
radio-bot-f4be8d32c80d2b975b8ea59e3488cd1084269856.tar.bz2
radio-bot-f4be8d32c80d2b975b8ea59e3488cd1084269856.zip
Adds Fallbacks for loadout retrievals
Diffstat (limited to 'src')
-rw-r--r--src/main.js14
1 files changed, 9 insertions, 5 deletions
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; }