I'm creating a discord bot that I use multi-threading to update an ArrayList every few minutes. The first 'update' works correctly with no error, though every update afterwards I get the error:
[JDA MainWS-ReadThread] ERROR RestAction - RestAction queue returned failure
java.lang.IllegalStateException: This interaction has already been acknowledgdge an interaction once!
I'm creating the threads in Multithread.java
which says:
public static void main(String[] args) throws InterruptedException {
// Create a new bot
Thread startApp = new Thread(new App());
// Start the thread
startApp.start();
// Create new thread for updating
new App();
Thread updateTeams = new Thread(App.updateAll());
updateTeams.start();
}
The ArrayList that i'm updating (OCETeams) is in App.java and is public and static.
In App.java
, I have the following methods that relate to this:
@Override
public void run() {
try {
System.out.println("Starting.............");
initialize();
} catch (LoginException | ParseException | InterruptedException e) {
e.printStackTrace();
}
}
// For the 'updating' thread
public static Runnable updateAll() {
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
try {
System.out.println("Updating all");
OCETeams = getOCETeams();
System.out.println("OCE teams updated");
} catch (ParseException e) {
e.printStackTrace();
}
}
} , 0, 60000 * 20);
return null;
}
CodePudding user response:
In essence you have already replied for example and you are trying to reply again which throws the error and there is not enough info from the code you provided.