From 291db336922d4bc0145068a72a615d1c9ae86d5b Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Tue, 21 Feb 2023 18:41:47 -0500 Subject: [PATCH] Stop checking ratelimits --- main.js | 24 ++++++++++++++++++++++++ package.json | 1 + 2 files changed, 25 insertions(+) diff --git a/main.js b/main.js index bf488ba..bb04f20 100755 --- a/main.js +++ b/main.js @@ -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); diff --git a/package.json b/package.json index b20612d..832307a 100755 --- a/package.json +++ b/package.json @@ -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",