Page MenuHomedesp's stash

EightBall.java
No OneTemporary

EightBall.java

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.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) {
if (args.length < 1)
return new CommandResult(CommandResultType.INVALIDARGS, "Well, what do you even want to ask?");
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-java
Expires
Sun, Jul 6, 3:55 AM (21 h, 21 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
a9/a1/98147252c90beda3849722c127fd

Event Timeline