extra tools to use with the bot
This commit is contained in:
		
							parent
							
								
									afeb5b6837
								
							
						
					
					
						commit
						929cb7a65b
					
				
							
								
								
									
										58
									
								
								modules/utils.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								modules/utils.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,58 @@ | ||||
| /* eslint-disable no-case-declarations */ | ||||
| /* eslint-disable indent */ | ||||
| // dotenv for handling environment variables
 | ||||
| const dotenv = require('dotenv'); | ||||
| dotenv.config(); | ||||
| const token = process.env.TOKEN; | ||||
| 
 | ||||
| // Discord.JS
 | ||||
| const { Client, GatewayIntentBits, Partials } = require('discord.js'); | ||||
| const client = new Client({ | ||||
| 	intents: [ | ||||
| 		GatewayIntentBits.Guilds, | ||||
| 		GatewayIntentBits.GuildMessages, | ||||
| 		GatewayIntentBits.GuildMessageReactions, | ||||
| 		GatewayIntentBits.MessageContent | ||||
| 	], | ||||
| 	partials: [ | ||||
| 		Partials.Channel, | ||||
| 		Partials.Message | ||||
| 	], | ||||
| }); | ||||
| 
 | ||||
| // Various imports
 | ||||
| const fn = require('../modules/functions.js'); | ||||
| 
 | ||||
| client.once('ready', async () => { | ||||
|     watchRequestRates(); | ||||
| 	console.log('Ready!'); | ||||
|     const count = JSON.stringify(client.guilds.cache.size); | ||||
|     console.log(count); | ||||
| }); | ||||
| 
 | ||||
| client.login(token); | ||||
| 
 | ||||
| 
 | ||||
| async function watchRequestRates() { | ||||
|     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 watchRequestRates(); | ||||
|     }); | ||||
| } | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user