Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/org/jointheleague/discord_bot_example/Bot.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jointheleague/modules/CovidCaseGetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/org/jointheleague/modules/CurrencyConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
38 changes: 38 additions & 0 deletions src/main/java/org/jointheleague/modules/Lottery.java
Original file line number Diff line number Diff line change
@@ -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!");
}
}

}
4 changes: 2 additions & 2 deletions src/main/resources/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"channels": ["channelName"],
"token": "discordToken"
"channels": ["bot-testing"],
"token": "ODM1NjQzNjYxOTgyMTA1Njgz.YISbzg.ckN9PlWb3l5OI1E7V1iO1yx5Tx0"
}