Munxo
Munxo
DIAdiscord.js - Imagine an app
Created by Munxo on 7/12/2023 in #djs-questions
Trying to receive and log individual responses from two servers.
This kind of what you mean? I don’t think this would be viable, but I can’t check since I don’t have my Mac with me
41 replies
DIAdiscord.js - Imagine an app
Created by Munxo on 7/12/2023 in #djs-questions
Trying to receive and log individual responses from two servers.
client.on('interactionCreate', async (interaction) => {

if (interaction.commandName === 'rcon') {

const conn = new Rcon(process.env.HOST1_IP, process.env.HOST1_PORT, process.env.HOST1_PASS);
const conn2 = new Rcon(process.env.HOST2_IP, process.env.HOST2_PORT, process.env.HOST2_PASS);
const command = interaction.options.get('command').value;

console.log("Authenticated");
console.log("Sending command.")

conn.on('auth', function () {
conn.send(`/${command}`);
}).on('response',
function (‘**Server 1: **’ + str) {
console.log('Server 1: ' + str);
}).on('error', (error) => {
console.log('Error: ' + error);
});
interaction.deferReply();
conn.connect();

conn2.on('auth', function () {
conn2.send(`/${command}`);
}).on('response',
function (‘**Server 2: **’ + str) {
console.log('Server 2: ' + str);
});
interaction.deferReply();
conn2.connect();
};
interaction.editReply(‘**Server 1: **’ + str, ‘**Server 2: **’ + str);
},
);
client.on('interactionCreate', async (interaction) => {

if (interaction.commandName === 'rcon') {

const conn = new Rcon(process.env.HOST1_IP, process.env.HOST1_PORT, process.env.HOST1_PASS);
const conn2 = new Rcon(process.env.HOST2_IP, process.env.HOST2_PORT, process.env.HOST2_PASS);
const command = interaction.options.get('command').value;

console.log("Authenticated");
console.log("Sending command.")

conn.on('auth', function () {
conn.send(`/${command}`);
}).on('response',
function (‘**Server 1: **’ + str) {
console.log('Server 1: ' + str);
}).on('error', (error) => {
console.log('Error: ' + error);
});
interaction.deferReply();
conn.connect();

conn2.on('auth', function () {
conn2.send(`/${command}`);
}).on('response',
function (‘**Server 2: **’ + str) {
console.log('Server 2: ' + str);
});
interaction.deferReply();
conn2.connect();
};
interaction.editReply(‘**Server 1: **’ + str, ‘**Server 2: **’ + str);
},
);
41 replies
DIAdiscord.js - Imagine an app
Created by Munxo on 7/12/2023 in #djs-questions
Trying to receive and log individual responses from two servers.
So the first chunk connecting to Server 1 should be interaction.deferReply() then later after connecting and sending the command on Server 2 then I put in interaction.editReply({‘Server 1: ‘ + str}, {‘Server 2: ’ + str}) ?
41 replies
DIAdiscord.js - Imagine an app
Created by Munxo on 7/12/2023 in #djs-questions
Trying to receive and log individual responses from two servers.
This will also have to work with there being the possibility of variance with what the server spits back as a response. I want it to reply back with whatever information/content the server gives depending on the command used. So if I do: /teleport munxo munxo
41 replies
DIAdiscord.js - Imagine an app
Created by Munxo on 7/12/2023 in #djs-questions
Trying to receive and log individual responses from two servers.
I unsure as to what it should be equal to in order to benefit me the most for my desired outcome.
41 replies
DIAdiscord.js - Imagine an app
Created by Munxo on 7/12/2023 in #djs-questions
Trying to receive and log individual responses from two servers.
A let str =?
41 replies
DIAdiscord.js - Imagine an app
Created by Munxo on 7/12/2023 in #djs-questions
Trying to receive and log individual responses from two servers.
Sorry for my late response. I had to complete a scheduled job. I'm struggling a bit to follow. So, before my if (interaction.commandName === ... I should make a let str line?
41 replies
DIAdiscord.js - Imagine an app
Created by Munxo on 7/12/2023 in #djs-questions
Trying to receive and log individual responses from two servers.
That's what I have now and am testing
41 replies
DIAdiscord.js - Imagine an app
Created by Munxo on 7/12/2023 in #djs-questions
Trying to receive and log individual responses from two servers.
client.on('interactionCreate', async (interaction) => {
if (interaction.commandName === 'rcon') {

const conn = new Rcon(process.env.HOST1_IP, process.env.HOST1_PORT, process.env.HOST1_PASS, process.env.HOST2_IP, process.env.HOST2_PORT, process.env.HOST2_PASS);
const conn2 = new Rcon(process.env.HOST2_IP, process.env.HOST2_PORT, process.env.HOST2_PASS);
const command = interaction.options.get('command').value;

console.log("Authenticated");
console.log("Sending command.")

conn.on('auth', function () {
conn.send(`/${command}`);
}).on('response',
function (str) {
console.log('Server 1: ' + str);

}).on('error', (error) => {
console.log('Error: ' + error);
})
conn.connect();

conn2.on('auth', function () {
conn2.send(`/${command}`);
}).on('response',
function (str) {
console.log('Server 2: ' + str);

}).on('error', (error) => {
console.log('Error: ' + error);
})
conn2.connect();
};

let str = interaction.reply(`**Server 1: **`)

},
);
client.on('interactionCreate', async (interaction) => {
if (interaction.commandName === 'rcon') {

const conn = new Rcon(process.env.HOST1_IP, process.env.HOST1_PORT, process.env.HOST1_PASS, process.env.HOST2_IP, process.env.HOST2_PORT, process.env.HOST2_PASS);
const conn2 = new Rcon(process.env.HOST2_IP, process.env.HOST2_PORT, process.env.HOST2_PASS);
const command = interaction.options.get('command').value;

console.log("Authenticated");
console.log("Sending command.")

conn.on('auth', function () {
conn.send(`/${command}`);
}).on('response',
function (str) {
console.log('Server 1: ' + str);

}).on('error', (error) => {
console.log('Error: ' + error);
})
conn.connect();

conn2.on('auth', function () {
conn2.send(`/${command}`);
}).on('response',
function (str) {
console.log('Server 2: ' + str);

}).on('error', (error) => {
console.log('Error: ' + error);
})
conn2.connect();
};

let str = interaction.reply(`**Server 1: **`)

},
);
41 replies
DIAdiscord.js - Imagine an app
Created by Munxo on 7/12/2023 in #djs-questions
Trying to receive and log individual responses from two servers.
So what would you recommend? Which is going to be my simplest route? Still trying to deduce everything you've said.
41 replies
DIAdiscord.js - Imagine an app
Created by Munxo on 7/12/2023 in #djs-questions
Trying to receive and log individual responses from two servers.
I should still stay within this client.on('interactionCreate', async (interaction) => {} or within this client.on('interactionCreate', async (interaction) => { if (interaction.commandName === 'rcon') {}}
41 replies
DIAdiscord.js - Imagine an app
Created by Munxo on 7/12/2023 in #djs-questions
Trying to receive and log individual responses from two servers.
Yeah, so a single reply to the slash command saying something like Server 1: (playerinfo munxo): Name: Munxo / AGID: 123-123-123 / Dinosaur: N/A / Role: Manager / Marks: 4,819 / Growth: N/A Server 2: (playerinfo munxo): No player with the username 'Munxo'.
41 replies
DIAdiscord.js - Imagine an app
Created by Munxo on 7/12/2023 in #djs-questions
Trying to receive and log individual responses from two servers.
So like function server1() & function server2()?
41 replies
DIAdiscord.js - Imagine an app
Created by Munxo on 7/12/2023 in #djs-questions
Trying to receive and log individual responses from two servers.
Or would that be essentially impossible? I have tried to define the individual str 's of each command
41 replies
DIAdiscord.js - Imagine an app
Created by Munxo on 7/12/2023 in #djs-questions
Trying to receive and log individual responses from two servers.
Can you see a way to be able to pull the content spat back from "Server 1" and "Server 2" to create an
interaction.reply(`
**Server 1:** ${...}
**Server 2:** ${...}
`)
interaction.reply(`
**Server 1:** ${...}
**Server 2:** ${...}
`)
41 replies
DIAdiscord.js - Imagine an app
Created by Munxo on 7/12/2023 in #djs-questions
Trying to receive and log individual responses from two servers.
This is what I have
conn.on('auth', function () {
conn.send(`/${command}`);
}).on('response',
(str) => {
console.log('Server 1: ' + str);
interaction.reply('Server 1: ' + str);
}).on('error', (error) => {
console.log('Error: ' + error);
})
conn.connect();

conn2.on('auth', () => {
conn2.send(`/${command}`);
}).on('response',
(str) => {
console.log('Server 2: ' + str);
interaction.followUp('Server 2: ' + str);
}).on('error', (error) => {
console.log('Error: ' + error);
})
conn2.connect();
conn.on('auth', function () {
conn.send(`/${command}`);
}).on('response',
(str) => {
console.log('Server 1: ' + str);
interaction.reply('Server 1: ' + str);
}).on('error', (error) => {
console.log('Error: ' + error);
})
conn.connect();

conn2.on('auth', () => {
conn2.send(`/${command}`);
}).on('response',
(str) => {
console.log('Server 2: ' + str);
interaction.followUp('Server 2: ' + str);
}).on('error', (error) => {
console.log('Error: ' + error);
})
conn2.connect();
41 replies
DIAdiscord.js - Imagine an app
Created by Munxo on 7/12/2023 in #djs-questions
Trying to receive and log individual responses from two servers.
Server 2: (playerinfo munxo): No player with the username 'munxo'. /Users/mattmunson/Desktop/Desktop - Matt’s MacBook Pro/Test Bot/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:184 if (!this.deferred && !this.replied) return Promise.reject(new DiscordjsError(ErrorCodes.InteractionNotReplied)); ^ Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred. at ChatInputCommandInteraction.followUp (/Users/mattmunson/Desktop/Desktop - Matt’s MacBook Pro/Test Bot/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:184:64) at Rcon.<anonymous> (/Users/mattmunson/Desktop/Desktop - Matt’s MacBook Pro/Test Bot/index.js:229:23) at Rcon.emit (node:events:513:28) at Rcon._tcpSocketOnData (/Users/mattmunson/Desktop/Desktop - Matt’s MacBook Pro/Test Bot/node_modules/rcon/node-rcon.js:169:14) at Socket.<anonymous> (/Users/mattmunson/Desktop/Desktop - Matt’s MacBook Pro/Test Bot/node_modules/rcon/node-rcon.js:87:54) at Socket.emit (node:events:513:28) at addChunk (node:internal/streams/readable:324:12) at readableAddChunk (node:internal/streams/readable:297:9) at Readable.push (node:internal/streams/readable:234:10) at TCP.onStreamRead (node:internal/stream_base_commons:190:23) { code: 'InteractionNotReplied' } Node.js v18.16.1 [nodemon] app crashed - waiting for file changes before starting...
41 replies
DIAdiscord.js - Imagine an app
Created by Munxo on 7/12/2023 in #djs-questions
Trying to receive and log individual responses from two servers.
I will put them back in and post the error. One sec.
41 replies
DIAdiscord.js - Imagine an app
Created by Munxo on 7/12/2023 in #djs-questions
Trying to receive and log individual responses from two servers.
I have tried using interaction.reply() as well as interaction.followUp(), but no luck. It might have been the placement of that within my code.
41 replies
DIAdiscord.js - Imagine an app
Created by Munxo on 7/12/2023 in #djs-questions
Trying to receive and log individual responses from two servers.
I would like the bot to either reply or post a message with the content that is logged in the terminal (i.e. Server 1: (playerinfo munxo): No player with the username 'munxo'.
41 replies