diff --git a/src/main/java/org/jointheleague/discord_bot_example/Bot.java b/src/main/java/org/jointheleague/discord_bot_example/Bot.java index 06e330bf..41779e93 100644 --- a/src/main/java/org/jointheleague/discord_bot_example/Bot.java +++ b/src/main/java/org/jointheleague/discord_bot_example/Bot.java @@ -43,6 +43,10 @@ public void connect(boolean printInvite) { api.getServerTextChannelsByName(channelName).forEach(e -> e.sendMessage("Bot Connected")); //add Listeners + Lottery lotto = new Lottery(channelName); + api.addMessageCreateListener(lotto); + helpListener.addHelpEmbed(lotto.getHelpEmbed()); + DiscordLibrary dl = new DiscordLibrary(channelName); api.addMessageCreateListener(dl); helpListener.addHelpEmbed(dl.getHelpEmbed()); diff --git a/src/main/java/org/jointheleague/modules/CovidCaseGetter.java b/src/main/java/org/jointheleague/modules/CovidCaseGetter.java index 299fa5ca..29b5c230 100644 --- a/src/main/java/org/jointheleague/modules/CovidCaseGetter.java +++ b/src/main/java/org/jointheleague/modules/CovidCaseGetter.java @@ -14,7 +14,8 @@ public class CovidCaseGetter extends CustomMessageCreateListener { public CovidCaseGetter(String channelName) { super(channelName); - helpEmbed = new HelpEmbed(COMMAND, "Responds with live number of COVID-19 positive cases from the United States. Uses information & data from Johns Hopkins University Center for Systems Science and Engineering(JHU CSSE). Supported by Johns Hopkins University Applied Physics Lab. Data is updated every 10 minutes."); + helpEmbed = new HelpEmbed(COMMAND, "Responds with live number of COVID-19 positive cases from the United States. Uses information & data from Johns Hopkins University Center for Systems Science and Engineering(JHU CSSE). " + + "Supported by Johns Hopkins University Applied Physics Lab. Data is updated every 10 minutes."); } @Override diff --git a/src/main/java/org/jointheleague/modules/CurrencyConverter.java b/src/main/java/org/jointheleague/modules/CurrencyConverter.java index 57bc9950..b1795ffb 100644 --- a/src/main/java/org/jointheleague/modules/CurrencyConverter.java +++ b/src/main/java/org/jointheleague/modules/CurrencyConverter.java @@ -86,15 +86,15 @@ public void getConversionData() { //you can use postman to make the request and receive a response, then take that and put it right into jsonschema2pojo.com //If using jsonschema2pojo.com, select Target Langue = java, Source Type = JSON, Annotation Style = Gson conversions = gson.fromJson(userJSON.toString(), Conversions.class); - try { - conversions.getRates().initializeRatios2(); - } catch (IllegalArgumentException e) { + //try { + // conversions.getRates().initializeRatios2(); + //} catch (IllegalArgumentException e) { // TODO Auto-generated catch block // e.printStackTrace(); - } catch (IllegalAccessException e) { + //} catch (IllegalAccessException e) { // TODO Auto-generated catch block //e.printStackTrace(); - } + //} /* //get the first article (these are just java objects now) Article article = conversions.getArticles().get(0); diff --git a/src/main/java/org/jointheleague/modules/Lottery.java b/src/main/java/org/jointheleague/modules/Lottery.java new file mode 100644 index 00000000..c38d8658 --- /dev/null +++ b/src/main/java/org/jointheleague/modules/Lottery.java @@ -0,0 +1,38 @@ +package org.jointheleague.modules; + +import java.util.Random; + +import org.javacord.api.event.message.MessageCreateEvent; +import org.jointheleague.modules.pojo.HelpEmbed; + +import net.aksingh.owmjapis.api.APIException; + +public class Lottery extends CustomMessageCreateListener{ + public static final String COMMAND = "!PowerBall"; + public Lottery(String channelName) { + super(channelName); + helpEmbed = new HelpEmbed(COMMAND, "Use ! + PowerBall to get 5 random lotto numbers, inspired by the powerball Lottery!"); + } + int randInt = new Random().nextInt(99); + int randInt1 = new Random().nextInt(99); + int randInt2 = new Random().nextInt(99); + int randInt3 = new Random().nextInt(99); + int randInt4 = new Random().nextInt(99); + + @Override + public void handle(MessageCreateEvent event) throws APIException { + // TODO Auto-generated method stub + + String message = event.getMessageContent(); + if (message.equals(COMMAND)) { + event.getChannel().sendMessage("Hello, thank you for starting the lotto process! type !GetNumbers to start the process!"); + + } + else if (message.equals("!GetNumbers")) { + event.getChannel().sendMessage(("" + randInt + " ") + ("" +randInt1 + " ") + + ("" +randInt2 + " ")+ ("" +randInt3 + " ") + ("" +randInt4 + " ")); + event.getChannel().sendMessage("These are the winning lottory numbers for today!"); + } + } + +} diff --git a/src/main/resources/config.json b/src/main/resources/config.json index 0b58c8d9..0eb35cbe 100644 --- a/src/main/resources/config.json +++ b/src/main/resources/config.json @@ -1,4 +1,4 @@ { - "channels": ["channelName"], - "token": "discordToken" + "channels": ["bot-testing"], + "token": "ODM1NjQzNjYxOTgyMTA1Njgz.YISbzg.ckN9PlWb3l5OI1E7V1iO1yx5Tx0" }