Skip to content

Commit

Permalink
Merge pull request #42 from Mazawrath/beanlottery_fix
Browse files Browse the repository at this point in the history
Beanlottery fix
  • Loading branch information
Mazawrath authored Jan 1, 2019
2 parents 16d7615 + 815f4ea commit 865a7a0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,16 @@ public void onCommand(String[] args, DiscordApi api, ServerTextChannel serverTex

private String getRecentChangeLog() {
return "**New beanBOT update released.**\n" +
"Release can be found on https://github.com/Mazawrath/beanBOT/releases/tag/v3.0.0\n" +
"Detailed changelog can be found on https://github.com/Mazawrath/beanBOT/compare/v2.8.0...v3.0.0\n" +
"Release can be found on https://github.com/Mazawrath/beanBOT/releases/tag/v3.0.1\n" +
"Detailed changelog can be found on https://github.com/Mazawrath/beanBOT/compare/v3.0.0...v3.0.1\n" +
"\n" +
"**v3.0.0**\n" +
"**v3.0.1**\n" +
// "**New**\n" +
// "\t- Added the Bean Lottery.\n" +
"**Changes**\n" +
"\t- Completely redesigned way to build and run beanBOT.\n" +
"\t- Reverted Beanmas.\n" +
"\t- Added an automated way to do weekly bean lottery drawings.\n" +
"\t- Added `.beanlottery draw` that anyone can use to start a bean lottery drawing.";
// "**Bug Fixes**\n" +
// "\t- Fixed an issue where normal users had access to `.adminposthelp`.\n";
// "**Changes**\n" +
// "\t- Completely redesigned way to build and run beanBOT.\n" +
// "\t- Reverted Beanmas.\n" +
"**Bug Fixes**\n" +
"\t- Fixed an issue with `.beanlottery` not giving help information.\n";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,23 @@ public BeanLotteryCommand(Points points, Lottery lottery) {

public void onCommand(String[] args, DiscordApi api, ServerTextChannel serverTextChannel, User author, Server server) {
try {
if (args[0].equalsIgnoreCase("start")) {
if (!author.isBotOwner() && !server.isOwner(author)) {
serverTextChannel.sendMessage("Only " + api.getOwner().get().getDiscriminatedName() + " or " + server.getOwner().getDisplayName(server) + " can use this command.");
return;
} else {
serverTextChannel.sendMessage("Weekly drawings now active. When the bot has more than " + Points.pointsToString(Lottery.MIN_WEEKLY_VALUE) + " it will do an automatic drawing every 7 days.");
lottery.scheduleWeeklyDrawing(points, server, api, serverTextChannel);
if (args.length == 1) {
if (args[0].equalsIgnoreCase("start")) {
if (!author.isBotOwner() && !server.isOwner(author)) {
serverTextChannel.sendMessage("Only " + api.getOwner().get().getDiscriminatedName() + " or " + server.getOwner().getDisplayName(server) + " can use this command.");
return;
} else {
serverTextChannel.sendMessage("Weekly drawings now active. When the bot has more than " + Points.pointsToString(Lottery.MIN_WEEKLY_VALUE) + " it will do an automatic drawing every 7 days.");
lottery.scheduleWeeklyDrawing(points, server, api, serverTextChannel);
return;
}
} else if (args[0].equalsIgnoreCase("draw")) {
if (points.removePoints(author.getIdAsString(), api.getYourself().getIdAsString(), server.getIdAsString(), Points.LOTTERY_DRAWING_COST)) {
lottery.drawNumbers(points, server, api, serverTextChannel);
} else
serverTextChannel.sendMessage("You do not have enough beanCoin for this command");
return;
}
} else if (args[0].equalsIgnoreCase("draw")) {
if (points.removePoints(author.getIdAsString(), api.getYourself().getIdAsString(), server.getIdAsString(), Points.LOTTERY_DRAWING_COST)) {
lottery.drawNumbers(points, server, api, serverTextChannel);
return;
} else
serverTextChannel.sendMessage("You do not have enough beanCoin for this command");
}
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
try {
if (args.length == 1) {
if (Integer.parseInt(args[0]) > 200) {
serverTextChannel.sendMessage("You can only buy 200 tickets at a time.");
return;
Expand Down Expand Up @@ -97,8 +93,8 @@ public void onCommand(String[] args, DiscordApi api, ServerTextChannel serverTex
serverTextChannel.sendMessage("You do not have enough beanCoin to buy a ticket.");
} else
serverTextChannel.sendMessage("You must have 1 number with how many tickets you want to buy, " + Lottery.AMOUNT_DRAWN + " numbers >= " + Lottery.MIN_NUMBER + " and <= " + Lottery.MAX_NUMBER + ", or the word `draw` to have your own drawing.");
} catch (NumberFormatException | NullPointerException e) {
serverTextChannel.sendMessage("Invalid number(s).");
} catch (NumberFormatException | NullPointerException | InterruptedException | ExecutionException e) {
serverTextChannel.sendMessage("Invalid number(s) / bad things happened.");
}
}
}

0 comments on commit 865a7a0

Please sign in to comment.