Bye Travis #68
6 changed files with 12 additions and 19 deletions
|
|
@ -23,7 +23,7 @@ public class Hadder {
|
||||||
startBot();
|
startBot();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void startBot() {
|
private static void startBot() {
|
||||||
Config config = new Config("./config.json");
|
Config config = new Config("./config.json");
|
||||||
if (!config.fileExists()) config.create();
|
if (!config.fileExists()) config.create();
|
||||||
config.load();
|
config.load();
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,11 @@ public class Rethink {
|
||||||
private Connection conn;
|
private Connection conn;
|
||||||
private Config config;
|
private Config config;
|
||||||
|
|
||||||
public Rethink(Config config) {
|
Rethink(Config config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean connect() {
|
public void connect() {
|
||||||
try {
|
try {
|
||||||
conn = r.connection()
|
conn = r.connection()
|
||||||
.hostname(config.getDatabaseIP())
|
.hostname(config.getDatabaseIP())
|
||||||
|
|
@ -35,7 +35,6 @@ public class Rethink {
|
||||||
System.out.println(e.toString());
|
System.out.println(e.toString());
|
||||||
System.out.println("DB CONNECTION FAILED");
|
System.out.println("DB CONNECTION FAILED");
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect() {
|
public void disconnect() {
|
||||||
|
|
@ -46,8 +45,7 @@ public class Rethink {
|
||||||
private JSONArray getAsArray(String table, String where, String value) {
|
private JSONArray getAsArray(String table, String where, String value) {
|
||||||
try {
|
try {
|
||||||
String string = r.table(table).filter(row -> row.g(where.toLowerCase()).eq(value)).coerceTo("array").toJson().run(conn);
|
String string = r.table(table).filter(row -> row.g(where.toLowerCase()).eq(value)).coerceTo("array").toJson().run(conn);
|
||||||
JSONArray jsonArray = new JSONArray(string);
|
return new JSONArray(string);
|
||||||
return jsonArray;
|
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
return null;
|
return null;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
||||||
|
|
@ -33,14 +33,10 @@ public class GitHubCommand implements Command {
|
||||||
String website = "None";
|
String website = "None";
|
||||||
try {
|
try {
|
||||||
bio = json.getString("bio");
|
bio = json.getString("bio");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException ignored) {}
|
||||||
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
location = json.getString("location");
|
location = json.getString("location");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException ignored) {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!json.getString("blog").equals("")) website = json.getString("blog");
|
if(!json.getString("blog").equals("")) website = json.getString("blog");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public class ScreenshareCommand implements Command {
|
||||||
List<VoiceChannel> vcs = event.getGuild().getVoiceChannelsByName(String.join(" ", args), true);
|
List<VoiceChannel> vcs = event.getGuild().getVoiceChannelsByName(String.join(" ", args), true);
|
||||||
if (vcs.size() > 1) {
|
if (vcs.size() > 1) {
|
||||||
EmbedBuilder eb = new EmbedBuilder()
|
EmbedBuilder eb = new EmbedBuilder()
|
||||||
.setTitle("Please Choose a Voicechannel")
|
.setTitle("Please Choose a Voice Channel")
|
||||||
.setDescription("There is more than one channel with this name");
|
.setDescription("There is more than one channel with this name");
|
||||||
for (int i = 0; i < vcs.size(); i++) {
|
for (int i = 0; i < vcs.size(); i++) {
|
||||||
VoiceChannel voiceChannel = vcs.get(i);
|
VoiceChannel voiceChannel = vcs.get(i);
|
||||||
|
|
@ -54,14 +54,14 @@ public class ScreenshareCommand implements Command {
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
event.getChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.ERROR, new EmbedBuilder()
|
event.getChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.ERROR, new EmbedBuilder()
|
||||||
.setTitle("Wait, thats illegal")
|
.setTitle("Wait, that's illegal")
|
||||||
.setDescription("This isn't a Number.")).build()).queue();
|
.setDescription("This isn't a Number.")).build()).queue();
|
||||||
}
|
}
|
||||||
}, event.getJDA(), event.getAuthor());
|
}, event.getJDA(), event.getAuthor());
|
||||||
} else if (vcs.size()==0) {
|
} else if (vcs.size()==0) {
|
||||||
event.getChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.ERROR, new EmbedBuilder()
|
event.getChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.ERROR, new EmbedBuilder()
|
||||||
.setTitle("Hol' up")
|
.setTitle("Hol' up")
|
||||||
.setDescription("There is no Voicechannel named like this. \n\nNote: Make sure the Voicechannel is on this Guild.")).build()).queue();
|
.setDescription("There is no Voice Channel named like this. \n\nNote: Make sure the Voice Channel is on this Guild.")).build()).queue();
|
||||||
} else {
|
} else {
|
||||||
event.getChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.INFO, new EmbedBuilder()
|
event.getChannel().sendMessage(new MessageEditor().setDefaultSettings(MessageEditor.Messagetype.INFO, new EmbedBuilder()
|
||||||
.setTitle("Here's your Url to share your Screen")
|
.setTitle("Here's your Url to share your Screen")
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ import java.util.List;
|
||||||
|
|
||||||
public class CommandHandler {
|
public class CommandHandler {
|
||||||
|
|
||||||
List<Command> commandList;
|
private List<Command> commandList;
|
||||||
Config config;
|
private Config config;
|
||||||
|
|
||||||
public CommandHandler(List<Command> commandList, Config config) {
|
public CommandHandler(List<Command> commandList, Config config) {
|
||||||
this.commandList = commandList;
|
this.commandList = commandList;
|
||||||
|
|
@ -18,7 +18,6 @@ public class CommandHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(MessageReceivedEvent event, Rethink rethink, String prefix) {
|
public void handle(MessageReceivedEvent event, Rethink rethink, String prefix) {
|
||||||
StringBuilder regexBuilder = new StringBuilder().append("\\").append(prefix);
|
|
||||||
String invoke = event.getMessage().getContentRaw().replaceFirst(prefix, "").split(" ")[0];
|
String invoke = event.getMessage().getContentRaw().replaceFirst(prefix, "").split(" ")[0];
|
||||||
for (Command cmd : commandList) {
|
for (Command cmd : commandList) {
|
||||||
for (String label : cmd.labels()) {
|
for (String label : cmd.labels()) {
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public class Config {
|
||||||
public void create() {
|
public void create() {
|
||||||
try {
|
try {
|
||||||
if (Files.notExists(file)) {
|
if (Files.notExists(file)) {
|
||||||
file = Files.createFile(file);
|
Files.createFile(file);
|
||||||
}
|
}
|
||||||
Files.write(file, defaultConfigContent().getBytes());
|
Files.write(file, defaultConfigContent().getBytes());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue