#Loop error on client.on

8 messages · Page 1 of 1 (latest)

granite vessel
#
          client.on('message', message => {
            while(turn < maxturn) {
              console.log(turn)
              if (!battle_status) return;
              if (message.author.id != member.id) return;
              if (own_magic.indexOf(message.content) != -1 && message.author.id == member.id) {```

If own_magic not include message.content, gonna return.
i want just 1 return.. but gonna infinite loop started
drifting solar
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

eternal canopy
#

bc you're using while

jovial bone
#

also turn is clearly not even being greater than maxturn so that will go on forever.

tardy elm
#

You should also use messageCreate and not message

granite vessel
#

oh...
then using like this?

client.on('messageCreate', message => {
            while(turn < maxturn && battle_status == true) {
              console.log(turn)
              if (!battle_status) return;
              if (message.author.id != member.id) return;
#

or not using while?.

#

oh i got what is my problem