fixed a minor bug where the bot would exit immediately when deploying instead of waiting for the build to finish
parent
4b075d63ed
commit
22e0139466
|
@ -15,7 +15,6 @@ public class Main{
|
||||||
CheckDeploy check = new CheckDeploy(7500, "/var/www/deployment/Hacky-Quizbot/id.txt");
|
CheckDeploy check = new CheckDeploy(7500, "/var/www/deployment/Hacky-Quizbot/id.txt");
|
||||||
check.start();
|
check.start();
|
||||||
|
|
||||||
|
|
||||||
DiscordApi api = new DiscordApiBuilder().setToken(token).login().join();
|
DiscordApi api = new DiscordApiBuilder().setToken(token).login().join();
|
||||||
|
|
||||||
// Add a listener which answers with "Pong!" if someone writes "!ping"
|
// Add a listener which answers with "Pong!" if someone writes "!ping"
|
||||||
|
@ -40,29 +39,33 @@ public class Main{
|
||||||
this.filename = filename;
|
this.filename = filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String grabId() {
|
public String grabId() throws FileNotFoundException {
|
||||||
File file = new File(this.filename);
|
File file = new File(this.filename);
|
||||||
Scanner reader;
|
Scanner reader;
|
||||||
String id = new String();
|
String id = new String();
|
||||||
|
|
||||||
try {
|
|
||||||
reader = new Scanner(file);
|
reader = new Scanner(file);
|
||||||
while (reader.hasNextLine()) {
|
while (reader.hasNextLine()) {
|
||||||
id = reader.nextLine();
|
id = reader.nextLine();
|
||||||
}
|
}
|
||||||
reader.close();
|
reader.close();
|
||||||
}catch (FileNotFoundException e) {
|
|
||||||
System.err.println("File not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
this.id = this.grabId(); //replace with correct filename
|
try {
|
||||||
|
this.id = this.grabId();
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
System.err.println("Failed to grab ID on startup.");
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
String new_id = this.grabId();
|
String new_id = this.id;
|
||||||
|
try {
|
||||||
|
new_id = this.grabId();
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
System.err.println("Failed to check ID.");
|
||||||
|
}
|
||||||
if (!new_id.equals(this.id)) {
|
if (!new_id.equals(this.id)) {
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue