so im currently developing a software which hosts your vps automaticly and bypasses the gcloud free tier 50 hours limit. so anyways on the login part, it executes the command "gcloud auth login --no-launch-browser" and sends the link to a discord channel, but then, it requires a code, ive already setted up a message listner which executes after 7 seconds of sending the gcloud auth link.
so yeah how do I input the code, any help would be apreciated
heres my full code
const Discord = require("discord.js")
const { Client, Intents } = require('discord.js');
const { token, channelId } = require("./config.json");
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
var embed = new Discord.MessageEmbed()
client.on("ready", () => {
console.log(`(login bot) Logged in as ${client.user.tag}!`)
})
const { spawn } = require( 'child_process' );
client.on("message", msg => {
if (msg.content.startsWith("WARNING: The --[no-]launch-browser flags are deprecated and will be removed in future updates. Use --no-browser to replace --no-launch-browser.")){
msg.delete();
}
if(msg.content === '!ping2'){
embed = embed
.setDescription(`pong!2`)
.setColor("BLUE")
return msg.channel.send({embeds: [embed]})
}
if(msg.content.toLowerCase() === '!login'){
//collector
//collectors const
let filter = (m) => m.author.id === msg.author.id
let limit = 60000 * 15 //minute
const collected = {filter, time: limit, max: 1, errors: ['time']};
//collectors const
//aray
var colArray = {}
//collectorThing
const collector = async function() {
let genderEmbed = await msg.channel.send('Please enter in the code that you recived')
msg.channel
.awaitMessages(collected)
.then((collected) => {
let code = collected.first()
colArray.code = code
const codeCollected = spawn( 'echo', [ colArray.code ] );
codeCollected.stdout.on( 'data', ( data ) => {
msg.channel.send(data.toString())
} )
codeCollected.stderr.on( 'data', ( data ) => {
msg.channel.send(data.toString())
} )
codeCollected.on( 'out', ( code ) => {
msg.channel.send(code.toString())
} )
}
)
.catch(collected => {
console.log(collected)
})
}
//collectorEnd
'use strict';
const login = async function() {
const login = spawn( 'gcloud', [ 'auth', 'login', '--no-launch-browser' ] );
login.stderr.on( 'data', ( data ) => {
msg.channel.send(data.toString())
} )
}
login()
setTimeout(collector, 7000);
}
}
)
client.login(token)