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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.3</version>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/org/jointheleague/discord_bot_example/Bot.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ public void connect(boolean printInvite) {
api.addMessageCreateListener(mttt);
helpListener.addHelpEmbed(mttt.getHelpEmbed());

Greeter g = new Greeter(channelName);
api.addMessageCreateListener(g);
helpListener.addHelpEmbed(g.getHelpEmbed());
//Greeter g = new Greeter(channelName);
//api.addMessageCreateListener(g);
//helpListener.addHelpEmbed(g.getHelpEmbed());

pythagcalc pythagCalc = new pythagcalc(channelName);
api.addMessageCreateListener(pythagCalc);
Expand All @@ -142,6 +142,10 @@ public void connect(boolean printInvite) {
api.addMessageCreateListener(rps);
helpListener.addHelpEmbed(rps.getHelpEmbed());

CountingListener counting = new CountingListener(channelName);
api.addMessageCreateListener(counting);
helpListener.addHelpEmbed(counting.getHelpEmbed());

//old way to add listeners
api.addMessageCreateListener(helpListener);
api.addMessageCreateListener(new MomBot(channelName));
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/org/jointheleague/modules/CountingListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.jointheleague.modules;

import org.javacord.api.event.message.MessageCreateEvent;

import net.aksingh.owmjapis.api.APIException;

public class CountingListener extends CustomMessageCreateListener{
private static final String command= "!count";
int num=1;
public CountingListener(String channelName) {
super(channelName);
// TODO Auto-generated constructor stub
}

@Override
public void handle(MessageCreateEvent event) throws APIException {
// TODO Auto-generated method stub
String stringNum=""+num;
if(event.getMessageContent().contains(command)) {
String content=event.getMessageContent().replace(command, "").replaceAll(" ", "");
if(content.equals(stringNum)) {
num+=1;
event.addReactionsToMessage("👍");
}
else {
num=1;
event.getChannel().sendMessage("You broke the chain. The next number is 1.");
event.addReactionsToMessage("👎");
}
}
}

}
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": ["ellabot"],
"token": ""
"channels": ["jake-m"],
"token": "token"
}