Page MenuHomedesp's stash

No OneTemporary

diff --git a/src/me/despawningbone/discordbot/command/misc/EightBall.java b/src/me/despawningbone/discordbot/command/misc/EightBall.java
index 8e1d9d9..80dc4ec 100644
--- a/src/me/despawningbone/discordbot/command/misc/EightBall.java
+++ b/src/me/despawningbone/discordbot/command/misc/EightBall.java
@@ -1,61 +1,42 @@
package me.despawningbone.discordbot.command.misc;
+import java.util.Arrays;
+import java.util.List;
import java.util.Random;
import me.despawningbone.discordbot.command.Command;
import me.despawningbone.discordbot.command.CommandResult;
import me.despawningbone.discordbot.command.CommandResult.CommandResultType;
-import net.dv8tion.jda.api.MessageBuilder;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.User;
public class EightBall extends Command {
public EightBall() {
this.name = "8ball"; //override name
this.desc = "Ask the almighty 8ball!";
this.usage = "<question>";
}
+
+ private List<String> responses = Arrays.asList(
+ "`Seems true.`",
+ "`Oops. Don't count on that.`",
+ "`What did you say again?`",
+ "`Sure.`",
+ "`Nope. Just no.`",
+ "`Ask your mom.`",
+ "`Aint gonna answer ;)`",
+ "`I approve.`",
+ "`Chance of speaking the truth: 0.001%.`");
@Override
public CommandResult execute(TextChannel channel, User author, Message msg, String[] args) {
- Random randomno = new Random();
- MessageBuilder ans = new MessageBuilder();
- if (args.length < 1) {
+ if (args.length < 1)
return new CommandResult(CommandResultType.INVALIDARGS, "Well, what do you even want to ask?");
- } else {
- ans.append("The 8ball says:\n");
- int ran = randomno.nextInt(9) + 1;
- if (ran == 1) {
- ans.append("`Seems true.`");
- }
- if (ran == 2) {
- ans.append("`Oops. Don't count on that.`");
- }
- if (ran == 3) {
- ans.append("`What did you say again?`");
- }
- if (ran == 4) {
- ans.append("`Sure.`");
- }
- if (ran == 5) {
- ans.append("`Nope. Just no.`");
- }
- if (ran == 6) {
- ans.append("`Ask your mom.`");
- }
- if (ran == 7) {
- ans.append("`Aint gonna answer ;)`");
- }
- if (ran == 8) {
- ans.append("`I approve.`");
- }
- if (ran == 9) {
- ans.append("`Chance of speaking the truth: 0.001%.`");
- }
- }
- Message fans = ans.build();
- channel.sendMessage(fans).queue();
+
+ int choice = new Random().nextInt(responses.size());
+ channel.sendMessage("The 8ball says:\n" + responses.get(choice)).queue();
+
return new CommandResult(CommandResultType.SUCCESS);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sat, Sep 21, 3:59 PM (1 d, 16 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
5c/f4/c28d7b7bb5f86b5e674ea78178f6

Event Timeline