Add ability to type new contract in terminal
This commit is contained in:
parent
39472fd969
commit
95bade9c88
18
main.js
18
main.js
|
@ -6,6 +6,7 @@ const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { Client, GatewayIntentBits, EmbedBuilder } = require('discord.js');
|
const { Client, GatewayIntentBits, EmbedBuilder } = require('discord.js');
|
||||||
const Discord = require('discord.js');
|
const Discord = require('discord.js');
|
||||||
|
const readline = require('readline');
|
||||||
const envPath = path.resolve(__dirname, '.env');
|
const envPath = path.resolve(__dirname, '.env');
|
||||||
|
|
||||||
const obsWebSocketUrl = 'ws://localhost:4444';
|
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] });
|
const discordClient = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
|
||||||
let calculationInterval;
|
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() {
|
function restartCalculations() {
|
||||||
if (calculationInterval) {
|
if (calculationInterval) {
|
||||||
clearInterval(calculationInterval);
|
clearInterval(calculationInterval);
|
||||||
|
|
Loading…
Reference in New Issue