Closed shuhaowu closed 5 years ago
This is definitely not being scheduled correctly. I noticed that it only sends the message if either you get some event from discord, or the KeepAliveHandler in discord.py fires, which triggers a socket event.
This lead me to eventually look at how KeepAliveHandler works, and then I patched the code above with
asyncio.run_coroutine_threadsafe(self.client.send_typing(recipient), loop=self.client.loop)
asyncio.run_coroutine_threadsafe(self.client.send_message(destination=recipient, content=message), loop=self.client.loop)
This got rid of the lag problems.
Hi @shuhaowu !
Nice one :) Would you mind sending a PR with your modifications ?
Is there any other place we should use this function ?
I made a !ping command and I noticed that it will not send the reply until discord sends the bot some other event (for example, if you started typing and discord transmitted the typing event to the bot).
I suspect this has to do with the asyncio stuff that discordpy is using, specifically in the use of
Not quite sure how to fix it yet as I'm not too familiar with asyncio, tho.