Want to setup and confirm the rateLimit(ed) event

So I want to setup the rate limit event, but am having trouble getting it to fire, KinectThePascal suggested to edit channel, which does rate but doesn't fire the event, begins here: https://discord.com/channels/222078108977594368/824411059443204127/1050013001572421652 Code:
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildWebhooks,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.MessageContent,
],
partials: [
Partials.Channel, // Enable Partials, in hope of getting hidden webhooks
],
allowedMentions: {
parse: ['users', 'roles', 'everyone'],
},
rest: {
// have tried with this commented out too
rejectOnRateLimit: rateLimitData => {
return true; // rateLimitData.path.endsWith('/crosspost');
},
// have tried this, and 'rateLimit' too
// rateLimited: async (...args) => {
// console.log('Bot encountered a Rate Limit (client constructor)', [...args]);
// },
},
});

// have tried 'rateLimit' also
client.rest.on('rateLimited', async (...args) => {
console.log('Bot encountered a Rate Limit', [...args]);
});
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildWebhooks,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.MessageContent,
],
partials: [
Partials.Channel, // Enable Partials, in hope of getting hidden webhooks
],
allowedMentions: {
parse: ['users', 'roles', 'everyone'],
},
rest: {
// have tried with this commented out too
rejectOnRateLimit: rateLimitData => {
return true; // rateLimitData.path.endsWith('/crosspost');
},
// have tried this, and 'rateLimit' too
// rateLimited: async (...args) => {
// console.log('Bot encountered a Rate Limit (client constructor)', [...args]);
// },
},
});

// have tried 'rateLimit' also
client.rest.on('rateLimited', async (...args) => {
console.log('Bot encountered a Rate Limit', [...args]);
});
I have tried: Client({ rateLimited }) Client({ rateLimit }) Client({ rest: { rateLimited } }) Client({ rest: { rateLimit } }) client.on('rateLimit' client.on('rateLimited' client.rest.on('rateLimit' client.rest.on('rateLimited' Least I'm pretty sure I've tried all these... I am using a quick prefix-command to trigger the rate limits: Channel Edit Errored RateLimitError[/channels/:id]
} else if (message.content.startsWith('renameChannel')) {
const [com, num] = message.content.split(' ');

const guild = client.guilds.cache.get('770233729343160362');
const ch = guild.channels.cache.get('1025347371405692950');
ch.edit({ name: `scouting-lighten-${num}` }).catch(error => console.log('Channel Edit Errored', error));
} else if (message.content.startsWith('renameChannel')) {
const [com, num] = message.content.split(' ');

const guild = client.guilds.cache.get('770233729343160362');
const ch = guild.channels.cache.get('1025347371405692950');
ch.edit({ name: `scouting-lighten-${num}` }).catch(error => console.log('Channel Edit Errored', error));
17 Replies
Unknown User
Unknown Userā€¢2y ago
Message Not Public
Sign In & Join Server To View
Syjalo
Syjaloā€¢2y ago
Try this in ready event console.log(client.rest.listenerCount('rateLimited'))
Yinoguns
Yinogunsā€¢2y ago
console.log('listenerCount for rateLimited', client.rest.listenerCount('rateLimited'));
// listenerCount for rateLimited 1
console.log('listenerCount for rateLimited', client.rest.listenerCount('rateLimited'));
// listenerCount for rateLimited 1
So perhaps the event is registering, but we're not finding a reliable way to trigger it correctly šŸ¤” that or there is a DJS bug?
MrMythical
MrMythicalā€¢2y ago
So you are editing the channel with a different name each time right?
Syjalo
Syjaloā€¢2y ago
Are you on Node.js v18?
Yinoguns
Yinogunsā€¢2y ago
ah, I am on v16 on this machine
Syjalo
Syjaloā€¢2y ago
Should be fine
MrMythical
MrMythicalā€¢2y ago
16.9+ right?
Yinoguns
Yinogunsā€¢2y ago
v16.13.0
MrMythical
MrMythicalā€¢2y ago
What about this?
Yinoguns
Yinogunsā€¢2y ago
Yea I was incrementing the name each time...except for when it was erroring, then I just did the same name each time to continue the errors anyway Small correction(s), I'm on: DJS v14.3.0 Node v16.13.0
MrMythical
MrMythicalā€¢2y ago
Could you update djs?
Yinoguns
Yinogunsā€¢2y ago
My thinking too, will do so now Fully Updated, will give the variations another go when I can
ckohen
ckohenā€¢2y ago
channel name changes encounter a sublimit, sublimits do not fire the ratelimited event because they hit the ratelimit (intentionally) on the first go around
Yinoguns
Yinogunsā€¢2y ago
ah, so which could I force to make the event fire @ckohen šŸ¤” ?
ckohen
ckohenā€¢2y ago
reactions react twice back to back and it'll fire
Yinoguns
Yinogunsā€¢2y ago
ah, let me try Like a boss, thank you friend:
Bot encountered a Rate Limit [
{
timeToReset: 349,
limit: 1,
method: 'PUT',
hash: '7d7314b2b07cb8156bbdb7bdb12f2dfa',
url: 'https://discord.com/api/v10/channels/1050056779008069662/messages/1050056815448166511/reactions/%E2%9D%A4/@me',
route: '/channels/:id/messages/:id/reactions/:reaction',
majorParameter: '1050056779008069662',
global: false
}
]
Bot encountered a Rate Limit [
{
timeToReset: 349,
limit: 1,
method: 'PUT',
hash: '7d7314b2b07cb8156bbdb7bdb12f2dfa',
url: 'https://discord.com/api/v10/channels/1050056779008069662/messages/1050056815448166511/reactions/%E2%9D%A4/@me',
route: '/channels/:id/messages/:id/reactions/:reaction',
majorParameter: '1050056779008069662',
global: false
}
]
Interestingly doing:
Client({
...
rest: {
rateLimited: async (...args) => {
console.log('Bot encountered a Rate Limit (client constructor)', [...args]);
},
}
});
Client({
...
rest: {
rateLimited: async (...args) => {
console.log('Bot encountered a Rate Limit (client constructor)', [...args]);
},
}
});
Doesn't trigger, so gonna stick with client.rest.on Did this to force the error:
} else if (message.content.startsWith('reactEnvoke')) {

const channel = message.guild.channels.cache.get('1050056779008069662');

const msg = await channel.messages.fetch('1050056815448166511');

await msg.react('šŸ˜˜');
await msg.react('ā¤');
} else if (message.content.startsWith('reactEnvoke')) {

const channel = message.guild.channels.cache.get('1050056779008069662');

const msg = await channel.messages.fetch('1050056815448166511');

await msg.react('šŸ˜˜');
await msg.react('ā¤');
āœ… Resolved ā¤ļø