Stop checking ratelimits

This commit is contained in:
Skylar Grant 2023-02-21 18:41:47 -05:00
parent 1b0269c304
commit 291db33692
2 changed files with 25 additions and 0 deletions

24
main.js
View File

@ -31,6 +31,7 @@ client.once('ready', async () => {
fn.collectionBuilders.slashCommands(client); fn.collectionBuilders.slashCommands(client);
await fn.collectionBuilders.guildInfos(client); await fn.collectionBuilders.guildInfos(client);
await fn.collectionBuilders.messageCollectors(client); await fn.collectionBuilders.messageCollectors(client);
checkRateLimits();
console.log('Ready!'); console.log('Ready!');
client.user.setActivity({ name: strings.activity.name, type: ActivityType.Watching }); client.user.setActivity({ name: strings.activity.name, type: ActivityType.Watching });
if (isDev == 'false') { if (isDev == 'false') {
@ -85,6 +86,29 @@ client.on('interactionCreate', async interaction => {
} }
}); });
async function checkRateLimits(hi) {
const axios = require('axios');
// Make a GET request to the Discord API
await axios.get('https://discord.com/api/v10/users/@me', {
headers: {
'Authorization': `Bot ${token}`
}
}).then(response => {
// Get the rate limit headers
const remaining = response.headers['x-ratelimit-remaining'];
const reset = response.headers['x-ratelimit-reset'];
// Log the rate limit headers
console.log(`Remaining requests: ${remaining}`);
console.log(`Reset time (Unix epoch seconds): ${reset}`);
}).catch(error => {
console.error(error);
});
await fn.sleep(500).then(async () =>{
await checkRateLimits();
})
}
process.on('unhandledRejection', error => { process.on('unhandledRejection', error => {
console.error('Unhandled promise rejection:', error); console.error('Unhandled promise rejection:', error);

View File

@ -17,6 +17,7 @@
}, },
"homepage": "https://github.com/voidf1sh/silvanus#readme", "homepage": "https://github.com/voidf1sh/silvanus#readme",
"dependencies": { "dependencies": {
"axios": "^1.3.3",
"discord.js": "^14.7.1", "discord.js": "^14.7.1",
"dotenv": "^16.0.3", "dotenv": "^16.0.3",
"mysql": "^2.18.1", "mysql": "^2.18.1",