Stop checking ratelimits

This commit is contained in:
Skylar Grant 2023-02-21 18:41:47 -05:00
parent cdb61cf602
commit e632dce612
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);
await fn.collectionBuilders.guildInfos(client);
await fn.collectionBuilders.messageCollectors(client);
checkRateLimits();
console.log('Ready!');
client.user.setActivity({ name: strings.activity.name, type: ActivityType.Watching });
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 => {
console.error('Unhandled promise rejection:', error);

View File

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