#Scheduled message causes duplicate messages in sharded app

12 messages · Page 1 of 1 (latest)

gentle mesa
#

I have a sharded bot that sends reminders, but sometimes the bot sends duplicate messages. I'm not sure how to prevent this. I've tried:

  • Storing the messageId in redis for 10 mins after successfully sending a message, then checking if redis has the messageId before sending, if not found, I send the message
  • Implemented mutex

I've observed duplicate reminders are being sent when too many messages are sent
Yet duplicate reminders are being sent. I'm not sure if this is the correct, what's the standard way to do reminders in a sharded bot?

wild nymphBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
  • Marked as resolved by staff
cunning reef
#

Best way would be by not using setTimeout but instead use a scheduler / cron that checks what reminders need to be sent

gentle mesa
cunning reef
#

You should run that system on one shard only of course. Or run it in ShardingManager process

gentle mesa
cunning reef
#

No. You can eval the send on one of your shards.

#

Or use /rest directly

gentle mesa
#

I'd also like to know how do I reload commands on all shards if commands is not attached to my client instance

cunning reef
#

Best way: By respawning the shards

#

Hot reload is a mess