#Extreme delay for sending messages

11 messages · Page 1 of 1 (latest)

tribal cairn
#

I've been working on a bot and I left it for a while, but when I came back I realized that messages (sending, not recieving) were sending much later than I expected. I inserted a console.time measurement and it took anywhere from 10 seconds to beyond 2 minutes for the message.reply, interaction.reply or message.channel.send to finish when awaited .

I used the following code posted by someone to see why this was happening:

client.rest.on('rateLimited', (rateLimitData) => {
  console.log(`Rate Limit Event`);
  console.log(`\tlimit: ${rateLimitData.limit}`);
  console.log(`\ttimeToReset: ${rateLimitData.timeToReset}`);
  console.log(`\turl: ${rateLimitData.url}`);
});

and when I sent the message, I'd get these rate limit warnings (img attached).

I don't know if they're related but it'd be great if someone could tell me what to fix or look out for. My bot only gets used by me and a couple of my friends in one server, so there shouldn't be a reason to hit rate limits. I've already tried resetting my token.

jade micaBOT
#

• 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.

tribal cairn
#
  • Discord version: v14.9.0
  • Node v18.12.1
  • No stack trace and code is too long to paste.
signal forge
#

Don't send messages too often

tribal cairn
#

I don't. I send a message, it sends one back.

#

Only myself and a couple of my friends use it. The bot isn't even used that frequently. The most its been used is when I'm testing it an even that doesn't pass more than a couple messages a minute.

signal forge
#

Use client.rest.on('rateLimited', console.log) to see the full data

tribal cairn
#

Rate limit logs like these keep sending every second or so (regardless of use/commands/messages):

{
  timeToReset: 51,
  limit: 50,
  method: 'GET',
  hash: 'Global(GET:/users/null)',
  url: 'https://discord.com/api/v10/users/null',
  route: '/users/null',
  majorParameter: 'global',
  global: true
}

These keep sending after the interaction.reply function is used and when the message is seen in the server:

{
  timeToReset: 68,
  limit: 50,
  method: 'POST',
  hash: 'Global(POST:/channels/:id/messages)',
  url: 'https://discord.com/api/v10/channels/554105109659910156/messages',
  route: '/channels/:id/messages',
  majorParameter: '554105109659910156',
  global: true
}

Oftentimes the timeToReset increases between the messages, if that is relevant.
I'm usually not that helpless when it comes to programming but I have no idea what's causing this. I checked (by deleting/commenting out) most of my code and there's no other API use.

signal forge
tribal cairn
#

That was my mistake, the logs are from when I tested it with message.channel.send, not interaction.reply

random imp
#

And the get /users/null is from you trying to client.users.fetch(null) for some reason