Add ability to type new contract in terminal
This commit is contained in:
		
							
								
								
									
										18
									
								
								main.js
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								main.js
									
									
									
									
									
								
							| @@ -6,6 +6,7 @@ const fs = require('fs'); | ||||
| const path = require('path'); | ||||
| const { Client, GatewayIntentBits, EmbedBuilder } = require('discord.js'); | ||||
| const Discord = require('discord.js'); | ||||
| const readline = require('readline'); | ||||
| const envPath = path.resolve(__dirname, '.env'); | ||||
|  | ||||
| const obsWebSocketUrl = 'ws://localhost:4444'; | ||||
| @@ -21,6 +22,23 @@ const ws = new WebSocket(obsWebSocketUrl); | ||||
| const discordClient = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] }); | ||||
| let calculationInterval; | ||||
|  | ||||
| const rl = readline.createInterface({ | ||||
|   input: process.stdin, | ||||
|   output: process.stdout | ||||
| }); | ||||
|  | ||||
| rl.on('line', (input) => { | ||||
|   console.log(`Received input: ${input}`); | ||||
|   updateTokenAndRestart(input.trim()); | ||||
| }); | ||||
|  | ||||
| function updateTokenAndRestart(newToken) { | ||||
|   currentToken = newToken; | ||||
|   console.log(`Token updated to: ${newToken}`); | ||||
|   updateEnvToken(newToken); | ||||
|   restartCalculations(); | ||||
| } | ||||
|  | ||||
| function restartCalculations() { | ||||
|   if (calculationInterval) { | ||||
|     clearInterval(calculationInterval); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user