Eddiebot: Bio has no output

Created on 5 Sep 2020  ·  3Comments  ·  Source: EddieJaoudeCommunity/EddieBot

Bio will not output if there is an empty array in Bio

if (roles) {
   const numberOfRoles = roles.length;
   embed.addField(`Roles (${numberOfRoles})`, roles.join(', ').toUpperCase());
}

We should check if the array is empty

if (roles) {
   const numberOfRoles = roles.length;
   if(numberOfRoles > 0) {
       embed.addField(`Roles (${numberOfRoles})`, roles.join(', ').toUpperCase());
   }
}
bug

Most helpful comment

We should check if the array is empty

if (roles) {
   const numberOfRoles = roles.length;
   if(numberOfRoles > 0) {
       embed.addField(`Roles (${numberOfRoles})`, roles.join(', ').toUpperCase());
   }
}
  1. How about simplifying this to…
if (roles && !!roles.length) {
  embed.addField(`Roles (${numberOfRoles})`, roles.join(', ').toUpperCase());
}
  1. Why do the roles SHOUT at you (uppercasing) anyway?

All 3 comments

We should check if the array is empty

if (roles) {
   const numberOfRoles = roles.length;
   if(numberOfRoles > 0) {
       embed.addField(`Roles (${numberOfRoles})`, roles.join(', ').toUpperCase());
   }
}
  1. How about simplifying this to…
if (roles && !!roles.length) {
  embed.addField(`Roles (${numberOfRoles})`, roles.join(', ').toUpperCase());
}
  1. Why do the roles SHOUT at you (uppercasing) anyway?
  1. I Agree
  2. No idea. That's how they were implemented before. I don't see why we couldn't change it.

Thanks @AllanRegush for fixing 👍 . Nice simplification @stemount .

I can't remember why the roles shout 🤷‍♂️ - but I agree, maybe leave that for now

Was this page helpful?
0 / 5 - 0 ratings