Trying to receive and log individual responses from two servers.
I am using Rcon to remotely connect to two game servers. I have created a slash command for my Discord bot to send whatever command typed in to both servers. I can get both of them to work, but I cannot get my bot to reply with both individual responses.
27 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Post the full error stack trace, not just the top part!
- Show your code!
- Explain what exactly your issue is.
- Not a discord.js issue? Check out #useful-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'.
Responding to interactions:
-
#reply
immediately respond with a message
- #update
immediately update the original message (buttons, select menus)
- #showModal
immediately show a modal (cannot be deferred)
- #deferReply/Update
respond later (up to 15 minutes)
- #followUp
post an additional message
The initial response has to happen within 3s of receiving the interaction!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.
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
I will put them back in and post the error. One sec.
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...
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
This is what I have
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
Scope
The scope is the current context of execution in which values and expressions are "visible" or can be referenced. If a variable or expression is not in the current scope, it will not be available for use. Scopes can also be layered in a hierarchy, so that child scopes have access to parent scopes, but not vice versa.
Can you see a way to be able to pull the content spat back from "Server 1" and "Server 2" to create an
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
Or would that be essentially impossible? I have tried to define the individual
str
's of each command
So like function server1()
& function server2()
?Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
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'.
I should still stay within this
client.on('interactionCreate', async (interaction) => {}
or within this client.on('interactionCreate', async (interaction) => {
if (interaction.commandName === 'rcon') {}}
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
So what would you recommend? Which is going to be my simplest route? Still trying to deduce everything you've said.
That's what I have now and am testing
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
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?Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
A
let str =
?Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
I unsure as to what it should be equal to in order to benefit me the most for my desired outcome.
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
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
Unknown User•17mo ago
Message Not Public
Sign In & Join Server To View
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})
?
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