From 0ca42ea59a1daa4604c5314884f0a99a23f77090 Mon Sep 17 00:00:00 2001 From: vatten Date: Sun, 21 Feb 2021 15:50:59 +0100 Subject: [PATCH] 8ball --- .../helpbot/bot/HelpBotInstance.java | 3 +- .../command/impl/other/EightBallCommand.java | 79 +++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/diamondfire/helpbot/bot/command/impl/other/EightBallCommand.java diff --git a/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java b/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java index f925688d..92ea39f7 100644 --- a/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java +++ b/src/main/java/com/diamondfire/helpbot/bot/HelpBotInstance.java @@ -111,7 +111,8 @@ public static void initialize() throws LoginException { new SupportBannedPlayersCommand(), new DiscussionMuteCommand(), new NbsCommand(), - new DailySessionsCommand() + new DailySessionsCommand(), + new EightBallCommand() ); JDABuilder builder = JDABuilder.createDefault(config.getToken()) diff --git a/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/EightBallCommand.java b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/EightBallCommand.java new file mode 100644 index 00000000..b45242ba --- /dev/null +++ b/src/main/java/com/diamondfire/helpbot/bot/command/impl/other/EightBallCommand.java @@ -0,0 +1,79 @@ +package com.diamondfire.helpbot.bot.command.impl.other; + +import com.diamondfire.helpbot.bot.command.argument.ArgumentSet; +import com.diamondfire.helpbot.bot.command.argument.impl.parsing.types.*; +import com.diamondfire.helpbot.bot.command.help.*; +import com.diamondfire.helpbot.bot.command.impl.Command; +import com.diamondfire.helpbot.bot.command.permissions.Permission; +import com.diamondfire.helpbot.bot.events.CommandEvent; +import net.dv8tion.jda.api.EmbedBuilder; + +import java.util.Random; + +public class EightBallCommand extends Command { + + @Override + public String getName() { + return "8ball"; + } + + @Override + public String[] getAliases() { + return new String[]{"8b"}; + } + + @Override + public HelpContext getHelpContext() { + return new HelpContext() + .description("Helps make decisions.") + .category(CommandCategory.OTHER) + .addArgument( + new HelpContextArgument() + .name("question") + .optional() + ); + } + + @Override + public ArgumentSet compileArguments() { + return new ArgumentSet() + .addArgument("question", + new SingleArgumentContainer<>(new MessageArgument()).optional("Is vatten super duper cool?")); + } + + @Override + public Permission getPermission() { + return Permission.USER; + } + + @Override + public void run(CommandEvent event) { + + String[] responses = new String[]{ + "No.", + "Yes.", + "Maybe..", + "Definitely!", + "How about no..", + "Good question..", + "Sure why not", + "Go for it!", + "Without a doubt.", + "Most likely.", + "Very doubtful.", + "Brilliant idea!", + //"Ask owen\nDM: <@246778942323818506>\nPING: <@246778942323818506>", + "Mhmm..", + }; + + Random rdm = new Random(); + EmbedBuilder builder = new EmbedBuilder(); + + builder.setTitle(":8ball: | " + event.getArgument("question")); + builder.setDescription(responses[rdm.nextInt(responses.length)]); + + event.getChannel().sendMessage(builder.build()).queue(); + } + +} +