Discord.js: issue: TextChannel#startTyping never stops typing

Created on 10 Apr 2018  Â·  6Comments  Â·  Source: discordjs/discord.js

Please describe the problem you are having in as much detail as possible:
Whenever startTyping is called, it runs, but never ends. Basically remaining in an infinite loop. Probably forgot to check for the count property of the typing entry and if it reaches 0, resolve the promise.

Include a reproducible code sample here, if possible:

msg.channel.startTyping(1);

Further details:

  • discord.js version: 12.0
  • node.js version: 9.9.0
  • Operating system: Windows 10 x64
  • Priority this issue should have – please be realistic and elaborate if possible: Low.

  • [ ] I found this issue while running code on a __user account__

  • [x] I have also tested the issue on latest master, commit hash: e84575803702576669eb02c647474430ac0295b8
won't fix

Most helpful comment

It can take a while to stop typing. Also, this is unrelated to the original issue.

image

All 6 comments

It appears to be working as intended - you cannot expect the bot to stop typing if you do not either send a message or call stopTyping(), so if you could elaborate farther that would be nice.
Edit: it actually doesn't if you simply send a message- if that's what you mean then it is probably indeed an issue. Though I am under the assumption you are misinterpreting the count parameter. It simply means basically how many times you have to tell it to stop typing for it to truly stop.

Well the bot does send a message and it doesn't stop... Soo /shrug

The bot will not stop typing until you tell it to by calling stopTyping.

try{
    message.channel.startTyping()
    await processCommand(message)
    message.channel.stopTyping()
}catch(e){
    console.log(e)
}

My code looks like above and the bot has significant delay between finishing the work and stop typing.
If the message doesn't start with a prefix processCommand() just simply returns without waiting, and executes the stopTyping() function immediately. Yet the bot doesn't stop typing only after 10-15 seconds or more.
I'm using latest 11.3.2 version.

It can take a while to stop typing. Also, this is unrelated to the original issue.

image

@neander-squirrel fyi, if processCommand throws an error, the bot won't stop typing in that channel, with the code you have shown. To avoid that, it should be more like:

try{
    message.channel.startTyping()
    await processCommand(message)
}catch(e){
    console.log(e)
}finally{
    message.channel.stopTyping()
}

or even just outside of the try-catch blocks, so that you always startTyping() the same number of times you stopTyping().

Was this page helpful?
0 / 5 - 0 ratings