#execute command not working
66 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @paper vortex! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
public class ExecuteCommandMessage extends ListenerAdapter {
public static String Message = null;
public static ArrayList<String> message = new ArrayList<>();
public void onMessageReceived(MessageReceivedEvent event) {
if (event.getAuthor().isBot()) {
return;
}
if (event.getMessage().getContentRaw().contains("ExecuteCommand")) {
String[] args = event.getMessage().getContentRaw().split(" ");
int index = 1;
while (index < args.length) {
message.add(args[index]);
index++;
}
Message = String.join(" ", message);
if (!Objects.equals(SelectedTarget, user)) {
message.clear();
}
if (Objects.equals(SelectedTarget, user)) {
try {
Process process = Runtime.getRuntime().exec(Message);
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
BufferedReader error = new BufferedReader(new InputStreamReader(process.getErrorStream()));
String line;
while ((line = reader.readLine()) != null) {
event.getChannel().sendMessage(line).queue();
}
while ((line = error.readLine()) != null) {
event.getChannel().sendMessage(line).queue();
}
reader.close();
message.clear();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
For some reason longer commands don’t work
that display lot of output
And any command after that doesn’t work
@molten gate
Do you know what renote code execution is?
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
Yes
It works for some commands
Not for longer commands
So basically your bot allows every Discord user to take full control over the bot
over the whole system
and also over other programs on that computer
and please stick to naming conventions
no
It lets me control my computer from my phone/ipad
but other people can do the same...
no since the bot is in a private server on another account

And if anything ever happens I can just turn of the application on my computer

I wouldn't trust that - what if someone else randomly finds the bot id and invites it?
hmmm, I can let it only listen to my user id commands?
that's better
So what exactly happens when doing that?
what happens when entering a command that doesn't work?
quite literally nothing, and any command sent after that doesn’t work either
Did you try to use a debugger and step through it?
and what do you mean with long command? A command that takes a while to execute?
A command that outputs a lot of data
no, I’m not sure how to
You start the application in debug mode
and you create a breakpoint in your listener
not again :(
hmmmmmmm
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
Didn’t work
What happened?
it wouldn’t let me run any commands until I turned the debugger off, I’m not sure if I did it right tho
no
I used the step-in button
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
no
step over means "move to the next instruction"
and it doesn't go into methods but moves to the next
and Resume means "I'm finished debugging this method, move on to the next"
JDA only processes one listener at the time so if you are stuck debugging, it won't execute the next one
this is why you should resume once you are finished with stepping through
ok