1

I tried to use this code:

if((data.memberData.workStreak || 0) >= 5){
            won+=400;
            embed.addField(message.language.get("WORK_CLAIMED_HEADINGS")[0], message.language.get("WORK_CLAIMED_SALARY", won))
            .addField(message.language.get("WORK_CLAIMED_HEADINGS")[1], message.language.get("WORK_AWARD"));
            data.memberData.workStreak = 0;
        } else {
            for(let i = 0; i < award.length; i++){
                if (typeof i === 'undefined') {
                   return '<:b_:682865394637078531>';
                }
                if(data.memberData.workStreak > i){
                    let letter = Discord.Util.parseEmoji(award[i]).name.split("_")[1];
                    award[i] = ":regional_indicator_"+letter+":";
                }
            }

But it did absolutely nothing. image

Any help?

1
  • + (letter || 'string') + Commented Mar 7, 2020 at 8:30

2 Answers 2

3

You can simply use the OR operator and print string instead of undefined. In below statement if a is undefined then it will store empty string in a instead of undefined.

a = a || ''

Replace your line with below line:

let letter =Discord.Util.parseEmoji(award[i]).name;
OR
let letter =Discord.Util.parseEmoji(award[i]);

Please find working snippit below:

const a = undefined;

console.log(a);
console.log(a || '');

Sign up to request clarification or add additional context in comments.

10 Comments

It didn't work really much. It still saying undefined
I have updated the code for your scenario. Can you please check and if the problem still persist then Can you please create jsfiddle displaying your issue ?
Did you check the updated answer for your scenario ? Please check my answer again. Your jsfiddle is not working. We can also chat if issue is still there
I updated it but didn't really do much aswell. instead i got this: cdn.discordapp.com/attachments/650265263006023680/…
on my config file. I put the this.client.config.emojis.letters.s to <:grey:685784080637231208>
|
0

I don't know exactly, what this little code snippet is aimed to do.. But may this could help you?

let letter = Discord.Util.parseEmoji(award[i]).name.split("_")[1];
if (letter == undefined) {
   return '<:b_:682865394637078531>';
}
if(data.memberData.workStreak > i){
    award[i] = ":regional_indicator_"+letter+":";
}

1 Comment

Nope. Still saying :regional_indicator_undefined:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.