简体   繁体   中英

Discord Bot Javascript Commands Else If Problem

i was building my discord bot, i wanted to make a currency command for 2 people: me and my friend. i was adding the if else statements and it worked fine for me, but i swapped the ID s to test if it would work for my friend, i added the statement "else if" and then the "else" was a problem, it said "Declaration or statement expected." but i did it correctly, there is too much code in the whole file so i'll only send the thing:

// >bal
case 'bal':
                if(userID==603873287071858701) {
                    bot.sendMessage({
                        to: channelID,
                        message: bal2
                    }) 
                    else if(userID==546721227671076864) {
                        bot.sendMessage({
                            to: channelID,
                            message: bal1
                        })
                    }
            break;

oh, and by the way, yes, i did add the values: "bal1, bal2" so it isn't that problem, i tried removing the "else", but that didn't do anything, btw the ID that starts with a 5 is my userID and the ID that starts with a 6 is my friend's id, i swapped them to test if it would work for my friend. what do i do to fix this problem? btw i'm using Visual Studio Code.

you forgat to close ( } ) the if statement before the else if statement. if it doesnt working try to log userID before the if statement to debug it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM